Image - Encryption - and - Decryption - BA Documentation
Image - Encryption - and - Decryption - BA Documentation
Submitted by
ARUN K 513318104004
HARIKRISHNAN M 513318104013
GOPI V 513317104009
BACHELOR OF ENGINEERING
In
MAY 2021
ANNA UNIVERSITY: CHENNAI 600 025
BONAFIDE CERTIFICATE
SIGNATURE SIGNATURE
Mr. D. PRABHU M.E., Mrs. G. JULIN LEEYA M.TECH,
HEAD OF THE DEPARTMENT SUPERVISOR
Assistant Professor, Teaching Fellow,
Department of CSE, Department of CSE,
University College of Engineering Arni, University College of Engineering,
Thatchur, Arni-632 326. Thatchur, Arni-632 326.
We take privilege to express few words of gratitude and respect to all those
who helped us in completion of this project. We thank the almighty God for giving
us the opportunity of doing this project work successfully. Our heartfelt thanks to
our beloved parents for their invaluable support to do this project.
With pleasure, we express our heart filled sincere thanks to our respected
Dean i/c Dr. R. ARULARASAN M.Tech., Ph.D., for giving moral support and
his constant association to successful completion of our mini project.
It’s our privilege to express our sincere thanks to the Head of the
Department i/c Mr. D. PRABU M.E., for his encouragement.
We also thank our mini project Guide Mrs. G. JULIN LEEYA M.Tech
who helped us a lot to do the project effectively and has given us a valuable
guidance in completing this project successfully. We thank our Project
Coordinator for his support and valuable suggestions during our project work.
We also extend our thanks to our Class Advisor and every member of the
faculty who provided valuable academic guidance, and their co-operation to do
this successful project. Finally, we would like to thank our parents, relatives and
friends for their encouragement and enthusiastic co-operation.
ABSTRACT
Blowfish algorithm (BA) is a secret-key symmetric block cipher, with a 64-bit block
size and variable key lengths from 32 bits up to a maximum of 448 bits. Once
still find it almost impossible to do anything with any encrypted data that might be
exposed. The attack on the system may be useless even if the intruder gets
the information because this information will be unknown. The end simulation
image results that the encrypted image cannot be accessed, and decrypted image
received can only be viewed. This project shows requirements for a standard
encryption algorithm, it may be possible to satisfy all requirements among the family
complex initialization phase required for encryption, the actual encryption of data is
i
TABLE OF CONTENTS
ABSTRACT i
LIST OF FIGURES v
LIST OF ABBREVATIONS vi
1 INTRODUCTION 1
1.1 Aim 1
2 EXISTING SYSTEM 3
3 PROPOSED SYSTEM 4
4 REQUIREMENT ENGINEERING 5
5 PROJECT DESCRIPTION 6
decryption
5.3 Modules 12
5.3.2 Encryption 12
5.3.3 Decryption 13
7 DEVELOPMENT TOOLS 18
7.1 General 18
9 REFERENCE 21
APPENDIX 22
SAMPLE CODE
LIST OF FIGURES
FIGURE NAME OF THE FIGURE PAGE NO
NO
5.2.2.1 Architectural design for encryption 8
5.2.3.1 Architectural design for decryption 9
5.2.4.1 Flow-diagram of each round Ri 10
5.2.4.2 Flow diagram for function – F 11
5.2.4.3 Flow diagram of post-processing step 11
5.3.1 User Interface creation 12
5.3.2 Encryption process 12
5.3.3 Decryption process 13
6.1 Image choosing window 14
6.2 Image icon saved in desktop 14
6.3 View of image_to_be_Encrypted.jpg 15
6.4 Image choosing 15
6.5 Name of the image displayed 16
6.6 Decrypted file saved in desktop 16
6.7 Encrypted file that cannot be viewed 17
6.8 Final decrypted image 17
v
LIST OF ABBREVATIONS
S.NO ABBREVATION EXPANSION
2. OS Operating System
vi
CHAPTER 1
INTRODUCTION
1.1 AIM
The aim of the project is to use cryptography concept in image encryption
and decryption using Blowfish algorithm.
1.2 OVERVIEW OF THE PROJECT
Encryption software has become important when it comes to protecting your
data. Hack attempts and privacy intrusions mean that it has become easier than
ever for completing strangers to access your most personal details stored on
your computer.
For businesses, its worse, as the exposure of sensitive or confidential records
can result in financial losses as well as heavy fines. While there are several
security solutions available, everything from free anti-malware tools for home
consumers and cloud anti-virus for business, even simple human error can
undermine these attempts to secure data.
Encryption software is already deployed by some large corporations and
government agencies to protect data, but its also available and now accessible
for a wider range of users.
Blowfish is a symmetric encryption algorithm, meaning that it uses the same
secret key to both Encrypt and Decrypt messages.
Blowfish is also a block cipher, meaning that it divides a message up into
fixed length blocks during encryption and decryption. The block length for
Blowfish is 64 bits; messages that are not a multiple of eight bytes in size must
be padded.
1
1.3 PROBLEM STATEMENT
In most IT systems, including desktop computer and internet, does not guarantee
security. Users with malicious intent have always found a way of exploiting one
vulnerability or the other. An attack that affects the confidentiality of information
often presents the platform for the integrity of such information to be compromised.
Interception information on transit would make little or no sense to an interceptor if
he is not able to decipher the content of the information, integrity of the information
remains uncompromised.
2
CHAPTER 2
EXISTING SYSTEM
Demerits
3
CHAPTER 3
PROPOSED SYSTEM
Merits:
1. Password hashing
2. Packet encryption
3. Bulk encryption
4
CHAPTER 4
REQUIREMENT ENGINEERING
Software OS Windows
NetBeans IDE 8.2
5
CHAPTER 5
PROJECT DESCRIPTION
6
5.2.1 BLOWFISH ALGORITHM
Blowfish is a symmetric encryption algorithm, meaning that it uses the same secret
key to both encrypt and decrypt messages. It is also a block cipher, meaning that it
divides a message up into fixed length blocks during encryption and decryption.
The block length for Blowfish is 64 bits, messages that are not a multiple of eight
bytes in size must be padded. Blowfish is public domain and was designed by Bruce
Schneier expressly for use in performance constrained environments such as
embedded systems. It has been extensively analyzed and said ‘reasonably secure’ by
the cryptographic community. Key terms involved in the Process:
7
5.2.2 ARCHITECTURAL DESIGN FOR ENCRYPTION
= XOR
64-bit PLAIN TEXT
32 64 32
P1
P1’
F
P1’ F1’
P2
P2’
F
P2’ F2’
(13 more iterations)
F15’ P15’
P16
P16’
F
P16’ F16’
P18
P17
32 64 32
32 64 32
P18
P18’
F
P18’ F18’
P17
P17’
F
P17’ F17’
(13 more iterations)
F15’ P15’
P3
P3’
F
P3’ F3’
P2
P1
32 64 32
32bit – XL 32bit -- XR
32bit -- Pi
32bit – XL 32bit -- XR
In the above diagram function ‘F’ has the following description shown below,
10
8-bit XA 8-bit XB 8-bit XC 8-bit XD
XA
add
xor
add
32-bit output
32-bit XL 32-bit XR
64-bit cipherText
Fig. 5.2.4.3 Flow diagram of post-processing step
11
5.3 MODULES
1. User Interface
2. Encryption
3. Decryption
5.3.1 USER INTERFACE
EncryptFile
class
JFrame
File Chooser
On creating a java class named EncryptFile that generates key for the encryption and
decryption methods, A new JFrame Form is created for user interface, it uses label,
buttons and text field and other components required for an application. File chooser
is opened as an event after clicking a button. After choosing, name of the file is
displayed on the text field. This image file is taken to next module.
5.3.2 ENCRYPTION
using
File Chooser Encrypt() Image to Encrypted
Cipher image
key
Fig. 5.3.2 Encryption process
12
Selected image’s path is sent to encrypt() as one of the arguments the other argument
is destination path, function encrypts the image using generated key from previous
module into cipher and then to Encrypted image obtained. This image is used for
decrypting in the next module.
5.3.3 DECRYPTION
DECRYPT
Encrypted Decrypt() Cipher to Decrypted
image MODE Image image
In this last module, encrypted image’s path is passed as an argument along with the
destination path of decrypted file. This image can be recognized by decrypt() and
using DECRYPT_MODE image is decrypted. It can be viewed that is saved in
desktop.
13
CHAPTER 6
IMPLEMENTATION AND SCREENSHOTS
6.1 CREATING AN IMAGE CHOOSING WINDOW
This module contains a window that chooses an image to use in the process
that contains label, button and text field for the application.
14
Fig. 6.3 View of image_to_be_Encrypted.jpg
15
Fig. 6.5 Name of the image displayed.
16
Fig. 6.7 encryptedFile.jpg cannot be viewed.
17
CHAPTER 7
DEVELOPMENT TOOLS
7.1 GENERAL
This module covers about the programming language used and components
added in the application window. Platform used here is JAVA.
7.2 FEATURES OF JAVA
7.2.1 OVERVIEW OF JAVA
JAVA, a programming language developed by James Gosling during 1995 at
Sun Microsystems. It is one of the most important language for developing software
applications and still growing. Java is a high-level, robust and an object-oriented
programming language, which is also a platform independent as it has runtime like
JRE. Codes in Java are compiled into byte code or machine independent code that
can run on Java Virtual Machine (JVM)
7.2.2 APPLICATIONS
Java is most commonly used in software applications, and very widely used
in hardware designing also by controlling its components. Some of the applications
of Java are,
Web Services
Desktop Softwares
Mobile OS – Android
Embedded Systems
7.2.3 TYPES OF JAVA APPLICATION
Using java, we can develop numerous applications of following types,
Standalone Application
Web Applications
Mobile Application
Enterprises Application
18
7.2.4 OBJECT ORIENTED
Java as an object-oriented programming language support concepts like
Classes, Objects and basic principles like Abstraction, Encapsulation, Inheritance
and Polymorphism. Benefits using these principles are,
Improved productivity during software development
Improved maintainability of software
Lower cost of developments
Higher quality software
7.3 JFRAME
The JFrame class is a type of container which inherits the java.awt.Frame
class. JFrame works like the main window where components like labels, buttons,
textfields are added to create a GUI. Almost every other Swing application starts
with the JFrame window. Unlike a frame, JFrame has the option to hide or close the
window with the help of the method setDefaultCloseOperation(int). All IDEs
provide Design view so that it reduces complexity for programmer, it can be
positioned by drag and drop method. Android studio is also application of Java
program, which helps in creating android applications.
19
CHAPTER 8
CONCLUSION AND FUTURE WORKS
At the end of the day, we need to protect our data. Increasing, encryption is seen as
the best way to ensure that data is protected, but the ever-growing use of encryption
creates a management challenge. This can be solved by using new techniques that
secures data, which reduces challenges. This project can be developed in future to
use it among networks, expanding its usage. User at the end can view the decrypted
final image, not the encrypted file. A simple text encryption can also be made along
with this image encryption. Hacking this method cannot be done as the image will
not be viewed and decrypting function can only recognize the encrypted image once
this process is completed. Blowfish can been used in variety of password
management tools, that encrypt and saves password, only the key scheduling takes
time but this is advantageous as brute force attacks will be more difficult.
20
REFERENCE
[1] R. E. Klima and N. Sigmon, “Cryptology: Classical and Modern
with Maplets,” Boca Raton, FL: CRC Press, 2012.
[4] A .Fiat , “Batch RSA,” in Proc. LNCS Conf. Crypto ’89, Berlin, 1989, pp.
175-185.
21
APPENDIX
SAMPLE CODE
Encrypting Part
public void encrypt(String srcPath,String destPath) throws InvalidKeyException,
FileNotFoundException, IOException, IllegalBlockSizeException, BadPaddingException
{
File rawFile = new File(srcPath);
File encryptedFile = new File(destPath);
InputStream inStream = null;
OutputStream outStream = null;
try{
cipher.init(Cipher.ENCRYPT_MODE,secretkey);
inStream = new FileInputStream(rawFile);
outStream = new FileOutputStream(encryptedFile);
byte[] buffer = new byte[1024];
int len;
while ((len=inStream.read(buffer)) > 0){
outStream.write(cipher.update(buffer,0,len));
outStream.flush();
}
outStream.write(cipher.doFinal());
inStream.close();
outStream.close();
try{
keygenerator = KeyGenerator.getInstance("Blowfish");
secretkey = keygenerator.generateKey();
cipher = Cipher.getInstance("Blowfish");
22
}catch(NoSuchPaddingException ex){
System.out.println(ex);
}catch(NoSuchAlgorithmException ex){
System.out.println(ex);
}catch(IllegalBlockSizeException ex){
System.out.println(ex);
}catch(BadPaddingException ex){
System.out.println(ex);
}catch(InvalidKeyException ex){
System.out.println(ex);
}catch(FileNotFoundException ex){
System.out.println(ex);
}catch(IOException ex){
System.out.println(ex);
}
}
Decrypting Part
public void decrypt(String srcPath,String destPath) throws InvalidKeyException,
FileNotFoundException, IOException, IllegalBlockSizeException, BadPaddingException{
File encryptedFile = new File(srcPath);
File decryptedFile = new File(destPath);
InputStream inStream = null;
OutputStream outStream = null;
try{
cipher.init(Cipher.DECRYPT_MODE,secretkey);
inStream = new FileInputStream(encryptedFile);
outStream = new FileOutputStream(decryptedFile);
byte[] buffer = new byte[1024];
23
int len;
while ((len=inStream.read(buffer)) > 0){
outStream.write(cipher.update(buffer,0,len));
outStream.flush();
}
outStream.write(cipher.doFinal());
inStream.close();
outStream.close();
}catch(IllegalBlockSizeException ex){
System.out.println(ex);
}catch(BadPaddingException ex){
System.out.println(ex);
}catch(InvalidKeyException ex){
System.out.println(ex);
}catch(FileNotFoundException ex){
System.out.println(ex);
}catch(IOException ex){
System.out.println(ex);
}
}
24