0% found this document useful (0 votes)
385 views

Image - Encryption - and - Decryption - BA Documentation

This document describes a student project on image encryption and decryption using the Blowfish algorithm. The project was completed by 4 students pursuing their bachelor's degree in computer science and engineering. It includes an introduction to the Blowfish algorithm, the architectural designs for encryption and decryption, flow diagrams of the processes, descriptions of the modules including the user interface, encryption, and decryption. It also provides screenshots of the implemented system and discusses the development tools used including Java. The goal of the project was to use cryptography concepts to encrypt and decrypt images for improved security and privacy.

Uploaded by

Manikandan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
385 views

Image - Encryption - and - Decryption - BA Documentation

This document describes a student project on image encryption and decryption using the Blowfish algorithm. The project was completed by 4 students pursuing their bachelor's degree in computer science and engineering. It includes an introduction to the Blowfish algorithm, the architectural designs for encryption and decryption, flow diagrams of the processes, descriptions of the modules including the user interface, encryption, and decryption. It also provides screenshots of the implemented system and discusses the development tools used including Java. The goal of the project was to use cryptography concepts to encrypt and decrypt images for improved security and privacy.

Uploaded by

Manikandan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

IMAGE ENCRYPTION AND DECRYPTION

USING BLOWFISH ALGORITHM


A MINI PROJECT REPORT

Submitted by

ARUN K 513318104004

HARIKRISHNAN M 513318104013

SANTHOSH RAGHUL D 513318104043

GOPI V 513317104009

Pursuing pre-final year of the degree

BACHELOR OF ENGINEERING

In

COMPUTER SCIENCE AND ENGINEERING

UNIVERSITY COLLEGE OF ENGINEERING ARNI

ANNA UNIVERSITY: CHENNAI 600 025

MAY 2021
ANNA UNIVERSITY: CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this project report titled “IMAGE ENCRYPTION


AND DECRYPTION USING BLOWFISH ALGORITHM” is the bonafide
work of “ARUN K (513318104004), HARIKRISHNAN M (513318104013),
SANTHOSH RAGHUL D (513318104043) and GOPI V (51337104009)”
who carried out the project work under my supervision.

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.

Submitted for the Project Viva-Voce Examination held on………………

INTERNAL EXAMINER EXTERNAL EXAMINER


ACKNOWLEDGEMENT

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

properly setup, even if your security software fails, thieves/intruders/hackers would

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

of algorithms based on the same cryptographic principles. Although there is a

complex initialization phase required for encryption, the actual encryption of data is

very efficient on large microprocessors.

i
TABLE OF CONTENTS

CHAPTER TOPIC PAGE NO

ABSTRACT i

LIST OF FIGURES v

LIST OF ABBREVATIONS vi

1 INTRODUCTION 1

1.1 Aim 1

1.2 Overview of the project 1

1.3 Problem Statement 2

2 EXISTING SYSTEM 3

2.1 Existing System and its demerits 3

3 PROPOSED SYSTEM 4

3.1 Proposed System and its merits 4

4 REQUIREMENT ENGINEERING 5

4.1 Software and Hardware requirements 5

5 PROJECT DESCRIPTION 6

5.1 General Description 6

5.2 Project Description 6

5.2.1 Blowfish Algorithm 7


5.2.2 Architectural design for 8
encryption

5.2.3 Architectural design for 9

decryption

5.2.4 Flow diagrams 10

5.3 Modules 12

5.3.1 User Interface 12

5.3.2 Encryption 12

5.3.3 Decryption 13

6 IMPLEMENTATION AND SCREENSHOTS 14

6.1 Creating an image choosing window 14

6.2 Location of the image 14

6.3 Post Description 16

7 DEVELOPMENT TOOLS 18

7.1 General 18

7.2 Features of Java 18

7.2.1 Overview of Java 18

7.2.2 Applications of Java 18

7.2.3 Types of Applications 18

7.2.4 Object Oriented 19


7.3 JFrame 19

8 CONCLUSION AND FUTURE WORKS 20

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

1. IDE Integrated Development Environment

2. OS Operating System

3. RAM Random Access Memory

4. JRE Java Runtime Environment

5. GUI Graphical User Interface

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

2.1 EXISTING SYSTEM AND ITS DEMERITS


There may exist many applications of encryption and decryption of various type of
file formats, and they mainly are available as web application not as offline software.
Many web applications are even costing high rates and requires high speed internet
connection. Older algorithms are used among the existing systems. Due to high
requirement in network speed some data during encryption may tend to lose or
simply it cannot be retrieved back properly on decryption. Hence, we tend to lose
the image’s uniqueness, and in some cases, valuable information hidden will be
missed. Even few offline systems will not constantly work within network as there
can be intruders within same network.

Demerits

1. There are very less image encrypting systems available offline.


2. Online encrypting systems require high speed internet.
3. Few systems are paid ones too.

3
CHAPTER 3
PROPOSED SYSTEM

3.1 PROPOSED SYSTEM AND ITS MERITS


The proposed system suggests a new concept of desktop application. It means that
users can use this application free of cost, and this system works even in offline
mode. The key generation is done automatically so there is no way intruders can
attack, on running the application the decrypted file saves in desktop itself and
cannot be interfered during the process.

Merits:

1. This system can be used offline.


2. Destination folder can be specified and changed.
3. The algorithm is faster and much better than DES encryption.

Algorithm used: Blowfish Algorithm.

Applications of this algorithm:

1. Password hashing
2. Packet encryption
3. Bulk encryption

4
CHAPTER 4

REQUIREMENT ENGINEERING

4.1 SOFTWARE AND HARDWARE REQUIREMENTS

Software/Hardware Element Specification/Version

Hardware Processor Intel core to duo


RAM 2GB
Hard Disk 100GB

Software OS Windows
NetBeans IDE 8.2

5
CHAPTER 5
PROJECT DESCRIPTION

5.1 GENERAL DESCRIPTION

 Cryptography is used to secure and protect data during communication.


It is helpful to prevent unauthorized person or group of users from
accessing any confidential data. Encryption and decryption are the two
essential functionalities of cryptography.

 A message sent over the network is transformed into an unrecognizable


encrypted message known as data encryption. At the receiving end, the
received message is converted to its original form known as decryption.

5.2 PROJECT DESCRIPTION


 On running this application, choose an image from the system. On
choosing an image, the absolute path is stored in a variable that is the
source path, destination folder and name of it is programmed so there
is no need to change it manually.
 Once file is chosen, the source and destination paths are passed as
arguments to encrypting and decrypting methods. Initially key is
generated automatically, encrypting and decrypting methods carry the
file and completes the process and stores in desired folder, in this case
it is saved in desktop for user convenience.
 Two files will be resulted as output, one encrypted image that cannot
be viewed by any image viewer, and another one is the decrypted image
which is the final output.

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:

1. Block Size: 64-bits


2. Key Size: 32-bits to 448-bits variable size
3. Number of subkeys: 18 [P-array]
4. Number of rounds: 16
5. Number of substitution boxes: 4 [each having 512 entries of 32-bits each]

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

64-bit CIPHER TEXT

Fig. 5.2.2.1 Architectural design for encryption


5.2.3 ARCHITECTURAL DESIGN FOR DECRYPTION

= XOR 64-bit CIPHER TEXT

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

64-bit PLAIN TEXT

Fig. 5.2.3.1 Architectural design for decryption


5.2.4 FLOW DIAGRAMS
The encryption consists of 16 rounds with each round (Ri) taking inputs the
Plaintext(P) from previous round and corresponding subkey (Pi). Flow diagram for
each round Ri.

32bit – XL 32bit -- XR

32bit -- Pi

32bit – XL 32bit -- XR

Fig 5.2.4.1 Flow-diagram of each round Ri

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

32 bit 32 bit 32 bit 32 bit

S-box 1 S-box 2 S-box 3 S-box 4

add

xor

add

32-bit output

Fig. 5.2.4.2 Flow diagram of Function - F


In the above diagram, ‘add’ is addition modulo 232. After 16 rounds of iteration the
final output will be as follows.

64-bit output from 16 rounds


32-bit XL 32-bit XR

32-bit P[1] 32-bit P[0]

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

Fig. 5.3.1 User Interface creation

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

Fig. 5.3.3 Decryption process

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.

Fig. 6.1 Image choosing window.

6.2 LOCATION OF THE IMAGE


Image used for encryption is saved in desktop that can be picked. Using
FileChooser in JFrame to select the image for the process.

Fig. 6.2 Image icon saved in desktop.

14
Fig. 6.3 View of image_to_be_Encrypted.jpg

Fig. 6.4 Image choosing.

15
Fig. 6.5 Name of the image displayed.

6.3 POST DECRYPTION


After decryption two files encrypted file and decrypted file will be saved in
desktop, out of these only decrypted image can be viewed.

Fig. 6.6 Decrypted file saved in desktop.

16
Fig. 6.7 encryptedFile.jpg cannot be viewed.

Fig. 6.8 decryptedFile.jpg – Final decrypted image.

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.

[2] R. L. Rivest, A. Shamir and L. Adleman “A method for obtaining


digital signatures and public-key cryptosystems” Communications of the ACM, vol.
21, pp. 120-126, 1978.

[3] R. Rivest, A. Shami and L. Aldeman, “A Method for Obtaining Digital


Signatures and Public-key Cryptosystems,” Communications of the ACM, vol. 21,
no. 2, pp. 120-126, 1978.

[4] A .Fiat , “Batch RSA,” in Proc. LNCS Conf. Crypto ’89, Berlin, 1989, pp.
175-185.

[5] L. Yunfei, L. Qing, L. Tong, and X. Wenming, “Two Efficient Methods to


Speed up the Batch RSA Decryption,” Third International Workshop on Advanced
Computational Intelligence, 2010.

[6] D.Boneh and H.Shacham, “Fast Variants of RSA,” RSA Laboratories


Cryptobytes Rep,2002, vol. 5 no. 1, pp. 1-8.

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

You might also like