CNS Final Project

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

VISVESVARAYA TECHNOLOGICAL

UNIVERSITY
JNANA SANGAMA , BELAGAVI - 590 014

MINI PROJECT REPORT ON


"IMPLEMENTATION ON IMAGE ENCRYPTION AND
DECRYPTION "
Submitted in partial fulfillment of the requirements for

COMPUTER NETWORK AND SECURITY [18CS52] IN


5th SEM COMPUTER SCIENCE AND ENGINEERING 2021-2022
SUBMITTED BY:

CHAYA T A 1GG19CS011
K CHANDRAMMA 1GG19CS020
UNDER THE GUIDENCE OF

Dr. CHETHAN K . C

Assistant professor Dept. of CS&E

GOVERNMENT ENGINEERING COLLEGE, RAMANAGARA

DEPARTMENT OF COMPUTER SCIENCE

GOVERNMENT ENGINEERING COLLEGE, RAMANAGARA


B.M ROAD, RAMANAGARA - 562159
CERTIFICATE

Certificate that the project entitled efficient “ IMPLIMENTATION OF IMAGE ENCRYPTION


AND DECRYPTION USING AES ALGORITHM” out by CHAYA T A, [1GG19CS011] ,
K CHANDRAMMA[1GG19CS020 ]
a bonafide by students of government engineering college, ramanagara-562159 , in partial fulfilment
for the award of Bachelor of Engineering in computer science of the Visvesharaya Technological
University, Belgaum-590018 during the year 2021-2022. It is certified that all corrections/suggestions
indicated for internal assessment have been incorporated in the report deposited in the department
library. The project has been approved as it satisfies the academic requirements with respect to the
project work prescribed for the said degree.

Date: Place: Ramanagara

Project Head of the department Principal


guide
Dr CHETHAN K C Dr. VASANTH G Dr. G PUNDARIKA

Asst.profess Asst.professor GEC


or
(dept. of (dept.of CSE) RAMANAGARA
CSE)

EXTERNAL VIVA

Name of examiners: Signature


1. …………………. ………………………
2. ………………. ………………......
4
INDEX

ABSTRACT

CHAPTER 1
INTRODUCTION

CHAPTER 2
LITERATURE SURVEY

CHAPTER 3
REQUIREMENT SPECIFICATIONS

CHAPTER 4
BLOCK DIAGRAM

CHAPTER 5
DESIGN

CHAPTER 6
IMPLEMENTATION

CHAPTER 7
RESULT

CONCLUSION

5
ABSTRACT

An Image Encryption and Decryption Using AES (Advance Encryption Standard) Algorithm is
proposed in this paper. Due to increasing use of image in various field, it is very important to protect the
confidential image data from unauthorized access. The design uses the iterative approach with block size of
128 bit and key size of 256 bit. The numbers of round for key size of 256 bits is 14. As secret key increases
the security as well as complexity of the cryptography algorithms.This paper presents a algorithm in which
the image is an input to AES Encryption to get the encrypted image and the encrypted image is the input to
AES Decryption to get the original image. security becomes an important issue in communication. For secure
transmission of data in open network, encryption is very important methodology. Though encryption we can
prevent our data from unauthorized access during transmission. In recent years many image encryption methods
have been proposed and used to protect confidential data. In this paper, we survey on existing work which is
used different techniques for image encryption and decryption we also give general introduction about
cryptography.

6
CHAPTER- 01

INTRODUCTION

The use of the internet and wireless communications has been rapidly growing andoccupying a wide
area in everyday life. Millions of users generate and interchange large amount of electronic data on a daily
basis in diverse domains. However, the issue of privacy and security is on the top of the crucial concerns which
determine the diffusion of such applications into the daily life. Hence, cryptography turns to become the key for
the reliability and effectiveness of the embedded system.

Nowadays cryptography has a main role in Embedded systems designs. In many applications, the data
requires a secured connection which is usually achieved by cryptography. Cryptography is divided in tw types
first is symmetric key cryptography (sender and receiver shares the same key) and the second one is asymmetric
key cryptography (sender and receiver shares different key) Symmetric systems contains Data Encryption
Standard (DES), 3DES, and AdvancedEncryption Standard (AES) use an identical key for the sender and
receiver.
Cryptographic process has two aspects: the algorithm and the key used for the encryption and decryption.
The use of the keys makes the cryptographic process reliable. There are two types of cryptographic mechanisms:
Symmetric key cryptography- uses same key for encryption and decryption process. Asymmetric key
cryptography - uses two different keys for encryption and decryption process. Symmetric key algorithm is
efficient, fast and easy to implement as compared to asymmetric key algorithm. The Advanced Encryption
Standard (AES) was published by the National Institute of Standards and Technology (NIST) in 2001. AES is a
subset of the Rijndael block cipher developed by two Belgian cryptographers, Vincent Rijmen and Joan Daemen.
AES is a symmetric block cipher and it is believed to be the standard process, So, it replaces DES algorithm in
most number of applications. When compared to other symmetric and public key ciphers, the AES symmetric
cipher is found to be complex.
Due to increasing use of computers, now a day security of digital information is most important issue.
Intruder is an unwanted person who reads and changes the information while transmission occurs. This activity
of intruder is called intrusion attack. To avoid such attack data may be encrypted to some formats that is
unreadable by an unauthorized person. AES is mainly advance version of data encryption standard (DES). Effort
towards developing the AES was started by NIST from January 1997. AES is a symmetric key encryption
algorithm, and NIST made a worldwide public call for the algorithm to succeed DES. Initially 15 algorithms
were selected. After detail analysis they were reduced down to 5 algorithms namely MARS, RC6, Rijndael,
Serpent and Twofish. All these algorithms were iterated block ciphers. The all five finalists were determined to
be qualified as the algorithm for AES.

7
In the current trends, the technologies have been advanced. Most of the individuals prefer using the internet
as the primary medium to transfer data from one end to another across the internet. There are many possible
ways to transmit data using the internet like: via e-mails, sending text and images, etc. In the present
communication world, images are widely in use. However, one of the main problems with sending data over the
Internet is the ‘security’ and authenticity. Data security basically means protection of data from unauthorized
users or attackers. Encryption is one of the technique for the information security. Image encryption is a
technique that convert original image to another form that is difficult to understand. No one can access the
content without knowing a decryption key. Image encryption has applications in corporate world, health care,
military operations, and multimedia systems. Encryption is the process of encoding plain text message into
cipher text message whereas reverse process of transforming cipher text to plain text is called as decryption.
Cryptography consists of encryption and decryption techniques. In this paper we have discuss about the various
encryption terminologies.the hands of user. Image encryption plays a significant role in the field of information
hiding. Image hiding or encryption methods and algorithms ranges from simple spatial domain methods to more
complicated and reliable frequency domain.
Computer has become an essential device now a days. The main use of computer is to store data and send
it from one location to other. The information that is shared must be transferred in a secured manner. To ensure
secured transmission of information, data is encrypted to unreadable formats by an unauthorized person.
Cryptography is the science of information security which has become a very critical aspect of modern
computing systems towards secured data transmission and storage. The exchange of digital data in cryptography
results in different algorithms that can be classified into two cryptographic mechanisms: symmetric key in which
same key is used for encryption and decryption and asymmetric key in which different keys are used for
encryption and decryption [1]. Asymmetric key algorithms are more secured when compared with symmetric
key algorithms. Nowadays, information security is primarily based on data storage and transmission.
The image encryption is to transmit the image securely over the network so that no unauthorized or any
unknown user can able to decrypt the image. Image encryption, video encryption have applications in many
fields including the internet communication, transmission, military Communication, etc. The progression of
encryption is moving towards a future of endless possibilities. The image data have special properties such as
bulk capability, high redundancy and high correlation among the pixels. Encryption techniques are very useful
tools to protect secret information. Encryption defined as the conversion of plain message into a cipher text that
cannot be read by any people without decrypting the encrypted text [1]. Decryption is the reverse process of
encryption which is the process of converting the encrypted text in to original plain text, so that it can be read
[1].Encryption of data [2] has become an important way to protect data resources especially available on the
internet, intranets and extranets and at any kind of network. Encryption is the process of applying special
mathematical algorithms and keys to transform digital data into cipher code before they are transmitted data.

CHAPTER -02
8
LITRATURE SURVEY

Advanced Encryption Standards

This is a project dealing with securing images over a network.Image is a delicate piece of
informationshared between clients across the world.Cryptography plays a huge role during secure
connections.Applying simple Gaussian elimination to achieve highly secured image encryption decryption
technique is a interesting challenge.
Advanced Encryption Standard (AES) also known as the rijindal alogorithm is a symmertric block cipher
It was recognized that DES was not secure because of advancement in computer processing power. The purpose
of NIST was to define a replacement for DES that can be used in non-military information security applications
by US government agencies. It can encrypt data blocks of 128 bits using symmetric keys 128,192,or 256. It has
variable key length of 128, 192, or 256 bits; default 256. It encrypts the data blocks of128 bits in 10, 12 and 14
round depending on the key size. AES encryption is fast and flexible. It can be implemented on various platforms
especially in small devices. AES has been tested for many security applications.
https://www.slideshare.net/vimal25792/aes-algorithm.
In this web site I have learned about the parameters of aes algorithm, uses of Aes algorithm,encryption and
decryption of aes algorithm , how aes algorithm is differ from des algorithm.

https://pdfs.semanticscholar.org/2f76/919e67b2f0c4a7f57bce3128a27c191b8460.pdf.
In this web site I have learned about the design and requirement specification of image encryption and
decryption by using aes algorithum.

https://www.slideshare.net/vimal25792/aes-shaping.
In this website I fetch the diagram and flow chart related to the aes algorithm and also the how aes algorithm
work in network communication and also implementation source code in java language.

Data structure text book 7th edition , in this I referred how to We use code and encryption and decryption of
aes algorithm.

9
10
CHAPTER-03

REQUIREMENT SPECIFICATION

SOFTWARE : ECLIPSE IDE

LANGUAGE : JAVA

11
12
CHAPTER-04

BLOCK DIAGRAM

13
14
CHAPTER -05

DESIGN

AES algorithm is of three types i.e. AES-128, AES-192 and AES-256. This classification is done onthe
bases of the key used in the algorithm for encryption and decryption process. The numbers represent the size
of key in bits. This key size determines the security level as the size of key increases the level of security
increases. The AES algorithm uses a round function that is composed of four different byte- oriented
transformations.

2 ADVANCED ENCRYPTION STANDARD

AES – PROCESS The characteristics of AES algorithm are given below –

• Uses common (Symmetric) key and so, it is called as Symmetric block cipher.

• The size of data is 128 bits, and so the key size varies from 128/192/256 bits.

• It is highly robust and 6 times faster than 3-DES and much faster and powerful than RSA.

• It uses single S-box for all rounds rather than DES, where it uses eight S-boxes.

The process involved in AES is iterative when compared with Fiestel cipher. AES is generally based on
Substitution and Permutations operations. It consists of sequence of linked operations at each round. Each
round consists of the following process. 1) Interchanging of inputs by the outputs produced by the substitution
process. 2) The bits are shifted in a cyclic manner. 3) The columns are mixed by transformation. 4) The key
has been added with input using XOR operation. The computation of AES is performed at bytes level, so 128
bits of plain-text is considered as a block of 16 bytes which constitute a 4x4 matrix. Each round of AES depends
on the key length. AES performs 10/12/14 rounds depending on the key size 128/192/256 respectively. So,
AES is known to be AES-128, AES-192 and AES-256 algorithm based on key size. A unique 128 bit round
key is given as an input at each round.

AES – Encryption and Decryption Specification AES is called AES-128, AES-192 and AES-256. This
classification depends on the different key size used for cryptographic process. Those different key sizes are
used to increase the security level. As, the key size increases the security level increases. Hence, key size is
directly proportional to the security level. The input for AES process is a single block of 128 bits. The
processing is carried out in several number of rounds where it depends on the key length: 16 byte key consists
of 10 rounds, 24 byte key consists of 12 rounds, and 32 byte key consists of 14 rounds. The first round of
encryption process consists of four distinct transformation functions:

• Substitution Bytes

• ShiftRows

15
• MixColumns

• AddRoundKey

• The final round consists of only three transformation ignoring MixColumns. The Decryption method is
the reverse of encryption and it consists of four transformations .

• Inverse Substitution Bytes

• Inverse ShiftRows

• Inverse MixColumns

• AddRoundKey

1.Encryption process

Substitute byte transformation

The Substitute bytes transformation is a non-linear byte substitution that operates independently on each
byte of the State using a substitution table S-box. The operation of substitute byte is shown in figure.

16
17
18
Mix columns transformation

The Mix Columns transformation operates on the State column-by-column, treatin

a four-term polynomial. The columns are considered as polynomials over GF(2^8) and multiplied
modulo x 4 + 1 with a fixed polynomial a(x), given by a(x) = {03}x ^3 + {01}x^ 2 + {01}x + {02} . The
resultant columnsare shown in the figure below. This is the operation of mix column.

Add round key transformation


In the Add Round Key transformation, a Round Key is added to the State by a simple bitwise XOR
operation. The Round Key is derived from the Cipher key by means of key schedule process. The State
andRound Key are of the same size and to obtain the next State an XOR operation is done per element: b (i,
j) = a (i, j) ⊕ k (i, j).

19
2) Decryption Process

Inverse Shift Rows is the inverse of the Shift Rows transformation. The bytes in the last three rows
of the State are cyclically shifted over different numbers of bytes. The first row, r = 0, is not shifted. The
bottom three rows are cyclically shifted by Nb-shift(r, Nb) bytes, where the shift value shift(r,Nb) depends
on the row number.

20
Inverse Substitute Bytes is the inverse of the byte substitution transformation, in which the inverse
S-box is applied to each byte of the State. It is reverse process of Substitute byte transform. This is obtained
by applying the inverse of the affine transformation followed by taking the multiplicative inverse in GF (2^8).
There is an inverse s-box table for substitute the value.

Inverse mix columns transformation

Inverse Mix Columns is the inverse of the Mix Columns transformation. Inverse Mix Columns
operates on the State column-by-column, treating each column as a four-term polynomial. The columns are
considered as polynomials over GF(2^8) and multiplied modulo x^ 4 + 1 with a fixed polynomial (x), given
by a^-1 (x) = {0b}x^3 + {0d}x^ 2 + {09}x + {0e}.
Inverse MixColumns is the inverse of Mixcolumns transformation. It carries out operations on matrix
by column-wise. Resultant columns are in the form of polynomials.

21
CHAPTER-05

IMPLEMENTATION

Execute On IDE:
• Open IDE like eclipse IDE.
• Create a new project
• Create a new class like Encryption or Decryption as required.
• Write the following code given below for encryption and Decryption in IDE.
• Just press Ctrl+S to save or you can go to file and click on save.
• Now, to run the code just select the class you want to execute like encryption then right-click.
• Run as a java application.
• Now, you will see the console window for output.

22
IMAGE ENCRYPTION
package chandu;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;

public class Encryption {


public static void main(String[] args)
throws FileNotFoundException, IOException
{
Scanner sc = new Scanner(System.in);
System.out.println("Note : Encryption Key act as Password to Decrypt the same Image,otherwise it will corrupt
the Image.");
System.out.print("Enter key for Encryption : ");
int key = sc.nextInt();
FileInputStream fis = new FileInputStream("C:\\Users\\Public\\Pictures\\Sample Pictures\\jellyfish.jpg");

byte data[] = new byte[fis.available()];


fis.read(data);
int i = 0; (byte b : data) {
data[i] = (byte)(b ^ key);
i++;
}
FileOutputStream fos = new FileOutputStream(
"C:\\Users\\Public\\Pictures\\Sample Pictures\\jellyfish.jpg");
fos.write(data);
fos.close();
fis.close();
System.out.println("Encryption Done...");

}
}
}

23
IMAGE DECRYPTION
package chandu;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;

public class Decryption {


public static void main(String[] args)
throws FileNotFoundException, IOException
{
Scanner sc = new Scanner(System.in);
System.out.println("Note : Encryption Key act as Password to Decrypt the same Image,otherwise it will
corrupt the Image.");
System.out.print("Enter a key for Decryption : ");
int key = sc.nextInt();
FileInputStream fis = new FileInputStream(
"C:\\Users\\Public\\Pictures\\Sample Pictures\\jellyfish.jpg");
byte data[] = new byte[fis.available()];
fis.read(data);
int i = 0;
for (byte b : data) {
data[i] = (byte)(b ^ key);
i++;
}
FileOutputStream fos = new FileOutputStream(
"C:\\Users\\Public\\Pictures\\Sample Pictures\\jellyfish.jpg");
fos.write(data);
fos.close();
fis.close();
System.out.println("Decryption Done...");
}
}

24
CHAPTER-06

RESULT

OUTPUT :

Note : Encryption Key act as Password to Decrypt the same Image,otherwise it will corrupt the Image.
Enter key for Encryption : 123
Encryption Done...

Note : Encryption Key act as Password to Decrypt the same Image,otherwise it will corrupt the Image.
Enter a key for Decryption : 123
Decryption Done...

25
26
CONCLUSION
Image Encryption and Decryption using AES algorithm is implemented to secure theimage data from an
unauthorized access. A Successful implementation of symmetric key AES algorithm is one of the best
encryption and decryption standard available in market. With the help of java coding implementation of an
AES algorithm is synthesized and simulated for Image Encryption and Decryption. The original images can
also be completely reconstructed without any distortion. It has shown that the algorithms have extremely
large security key space and can withstand most common attacks such as the brute force attack, cipher attacks
and plaintext attacks. In the field of information security, growth plays a main concern, growth means
change, change starts when we think an innovative concept. In this study, we introduce one in the
field of information security under image encryption topic. Image encryption can be defined in such
a way that it is the process of encoding secret image with the help of some encryption algorithm in
such a way that unauthorized users can’t access it.

27
28
29
30

You might also like