Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Image Encryption and Decryption Using AES, Assignments of Cryptography and System Security

A project report on Image Encryption and Decryption Using AES

Typology: Assignments

2019/2020
On special offer
30 Points
Discount

Limited-time offer


Uploaded on 06/07/2020

jahnavi-prathipati
jahnavi-prathipati 🇮🇳

3.8

(5)

6 documents

1 / 29

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Image Encryption and Decryption Using AES
Information and System Security
A PROJECT REPORT
Submitted by
P. Jahnavi - 17MIS7163
G. Baby Sai Meghana Chowdary 17MIS7082
Under the Guidance of
Dr. S. Sudhakar Ilango
Associate Professor, CSE,
VIT-AP
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
Discount

On special offer

Partial preview of the text

Download Image Encryption and Decryption Using AES and more Assignments Cryptography and System Security in PDF only on Docsity!

Image Encryption and Decryption Using AES

Information and System Security A PROJECT REPORT Submitted by P. Jahnavi - 17MIS G. Baby Sai Meghana Chowdary – 17MIS

Under the Guidance of Dr. S. Sudhakar Ilango Associate Professor, CSE, VIT-AP

TABLE OF CONTENTS

  • 1 Introduction Chapter No. Title Page No.
  • 2 Background Study
  • 3 Problem Definition
  • 4 Objective
  • 5 Methodology/Procedure
  • 6 Results and Discussion
  • 7 Conclusion and Future Scope
  • 8 References
    • Appendix – A : Coding
    • Appendix – B : Snap Shot

Chapter - Background Study AES, Advanced Encryption Standard is a symmetric-key algorithm based on the Rijndael cipher developed by Joan Daemen and Vincent Rijmen. The AES algorithm has a block size of 128 bits. It supports three different key lengths of 128, 192 and 256 bits. AES replaced Data Encryption Standard and it is now used worldwide. The cipher consists of rounds, where the number of rounds depends on the key length: 10 rounds for a 128 bit key, 12 rounds for 192 bit key, and 14 rounds for a 256 bit key. The whole algorithm operates on a 4 x 4 matrix of bytes. The first rounds consist of four distinct transformation functions: Sub Bytes, Shift Rows, Mix Columns, and Add Round Key. The final round contains three transformations. The Mix Columns function is not used in the final round. Each transformation takes one or more 4x4 matrices as input and produces a 4x4 matrix as output. Provided that all the four rounds are reversible, it is easy to prove that decryption does recover the plaintext

Chapter - Problem Definition

Many encryption methods have been proposed in literature, and the most common way to protect large multimedia files is by using conventional encryption techniques, Private key bulk encryption algorithms, such as Triple DES, are not so suitable for transmission of images. Due to complexity of their internal structure, they are not particularly fast in terms of execution speed and cannot be applied for images in the real time scenario Also traditional cryptographic techniques such as DES cannot be applied to images due to intrinsic properties of images such as bulk data capacity, redundancy and high correlation among pixels. Image encryption algorithms can become an integral part of the image delivery process if they aim towards efficiency and at same time preserve the security level.

Chapter - Methodology/Procedure

  1. Rounds
    1. Sub Bytes—a non-linear substitution step where each byte is replaced with another according to a lookup table.
    2. Shift Rows—a transposition step where the last three rows of the state are shifted cyclically a certain number of steps.
    3. Mix Columns—a mixing operation which operates on the columns of the state, combining the four bytes in each column.
    4. Add Round Key
  2. Final Round (no Mix Columns)
    1. Sub Bytes
    2. Shift Rows
    3. Add Round Key.

Chapter - Results and Discussion The experiments are performed on a Lenovo Laptop with Intel Core i3-4030U CPU running at 1.90GHz, and supported by 8GB of RAM. The algorithm proposed in this paper is implemented using NetBeansIDE-8.2. Crypto module is used for the AES algorithm. The implementation also provides an optional user friendly interface to perform encryption and decryption operations. By selecting images of various sizes, qualities and formats, an honest evaluation of the algorithm in terms of its efficiency, performance is made possible. We can also give different keys for same age and check whether it is same. Once a key is given to encrypt an image then the decryption must be with same key or else it doesn’t give the result. It is clear that the proposed algorithm can handle images of various categories, file sizes, qualities and resolutions. The size of the output is based on the key size specified in the encryption phase

References

  1. Kayhan CELİK and Erol KURT (2016): A New Image Encryption Algorithm Based on Lorenz System, ECAI 2016 – International Conference – 8th Edition Electronics, Computers and Artificial Intelligence, IEEE , pp: 23-28.
  2. Mohamed A. Mokhtar, Nayra M.Sadek and Amira G. Mohamed (2017), Design of Image Encryption Algorithm Based on Different Chaotic Mapping, 34th NATIONAL RADIO SCIENCE CONFERENCE, IEEE, pp: 197-204.
  3. Leo Yu Zhang, Yuansheng Liu, Fabio Pareschi, Yushu Zhang, Kwok-Wo Wong, Riccardo Rovatti and Gianluca Setti (2017): On the Security of a Class of diffusion Mechanisms for Image Encryption , IEEE, pp: 1-13.
  4. Yeter ŞEKERTEKİN, Özkan ATAN (2016): An Image Encryption Algorithm Using Ikeda and Henon Chaotic Maps, IEEE, pp: 1-4.
  5. Sushmita Singh and Musheer Ahmad, Dhruv Malik (2016): Breaking an Image Encryption Scheme Based on Chaotic Synchronization Phenomenon, IEEE, pp: 1-4.
  6. M. Zeghid, M. Machhout, L. Khriji, A. Baganne, and R. Tourki (2007): A Modified AES Based Algorithm for Image Encryption, International Journal of Computer, Electrical, Automation, Control and Information Engineering Vol: 1, No: 3, pp: 745-750.
  7. KirtiUpreti, Kriti Verma, and Anita Sahoo (2010): Variable Bits Secure System for Color Images, Second International Conference on Advances in Computing, Control, and Telecommunication Technologies, IEEE, pp: 105-

Appendix – A Coding import java.awt.; import java.awt.image.; import java.awt.event.; import javax.swing.; import javax.imageio.ImageIO; import java.io.File; import java.util.Random; import javax.crypto.; import javax.crypto.spec.; import static javax.swing.JFrame.EXIT_ON_CLOSE; class Main extends JFrame implements ActionListener{ private ImageRead panel; private ImageEncrypt encrypter; private File fileName; public Main(){ setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("JAVA-ImageCrypto"); setLayout(new BorderLayout()); panel = new ImageRead(); getContentPane().add(panel);

file.addSeparator();file.add(close); menu.add(setkey); menu.addSeparator(); menu.add(Encrypt); menu.add(Decrypt); help.add(about); menuBar.add(file); menuBar.add(menu); menuBar.add(help); open.addActionListener(this); setkey.addActionListener(this); close.addActionListener(this); save.addActionListener(this); Encrypt.addActionListener(this); about.addActionListener(this); saveas.addActionListener(this); Decrypt.addActionListener(this); return menuBar; } public void setFile(File file){ fileName = file; } public void actionPerformed(ActionEvent action) { String text = action.getActionCommand(); try{ if(text == "Open .."){ actionLoadImage(null); } else if(text == "Save"){ actionSaveImage(fileName); } else if(text == "Save as .."){ actionSaveImage(null);} else if(text == "Close "){ System.exit(0);} else if(text == "Set Pass Key"){ actionKeyDialog();

else if(text == "Encrypt Image"){ panel.setImage(encrypter.map(panel.getImage(),true,false)); } else if(text == "Decrypt Image"){ panel.setImage(encrypter.map(panel.getImage(),false,false)); } else if(text == "About"){ DisplayContactinfo(); } }catch(Exception err) { System.out.println("ERROR:" + err);} } public void actionKeyDialog(){ String key = new String(encrypter.getKey()); key = (String)JOptionPane.showInputDialog(this, "Enter a 16 byte key (current key= " + key.getBytes().length + " bytes)",key); while(key != null && key.getBytes().length != 16){ key = (String)JOptionPane.showInputDialog(this, "Enter a 16 byte key (current key= " + key.getBytes().length + " bytes)",key); }

public void actionSaveImage(File imageFile){ if(imageFile == null){ JFileChooser filechooser = new JFileChooser(fileName); filechooser.showSaveDialog(this); imageFile = filechooser.getSelectedFile(); }

if(imageFile != null){ try{ ImageIO.write(panel.getImage(), "png", imageFile); }catch(Exception e){ System.out.println("Error:" + e); } setFile(imageFile); } } public void DisplayContactinfo(){ JFrame contact = new JFrame("Contact info"); contact.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); contact.setSize(new Dimension(500, 430)); contact.setLayout(new BorderLayout()); contact.setDefaultCloseOperation(3); contact.setResizable(false);

JTextArea cont1 = new JTextArea(About); contact.add(new JScrollPane(cont1), BorderLayout.CENTER); cont1.setEditable(false); contact.setVisible(true); } public static void main(String args[]) { Main win = new Main(); win.setVisible(true); if(args.length > 0){ win.actionLoadImage(new File(args[0])); } } } class ImageRead extends JPanel{ private BufferedImage image; public ImageRead() { this.image = null; setFocusable(true); setLayout(null); setOpaque(true); }

private Cipher cipher; private SecretKeySpec skeySpec; ImageEncrypt() { try{ generator = new Random(); KeyGenerator kgen = KeyGenerator.getInstance("AES"); kgen.init(128); SecretKey skey = kgen.generateKey(); byte[] raw = skey.getEncoded(); skeySpec = new SecretKeySpec(raw, "AES");

cipher = Cipher.getInstance("AES/ECB/NoPadding"); }catch(Exception e){ System.out.println("ERROR: " + e);} } public void setKey(byte [] key){ skeySpec = new SecretKeySpec(key,"AES"); } byte [] getKey(){ return skeySpec.getEncoded();} public BufferedImage map(BufferedImage image,boolean encrypt,boolean trick) throws Exception{ if(image.getWidth() % 2 != 0 || image.getHeight() % 2 != 0){ throw(new Exception("Image size not multiple of 2 :(")); } BufferedImage encImage = new

BufferedImage(image.getWidth(),image.getHeight(), BufferedImage.TYPE_4BYTE_ABGR); if(encrypt){ System.out.println("Encrypting Image ... trick=" + trick); cipher.init(Cipher.ENCRYPT_MODE, skeySpec); } else{ System.out.println("Decrypting Image ... trick=" + trick); cipher.init(Cipher.DECRYPT_MODE, skeySpec); }

for(int x=0;x<image.getWidth(); x+=2){ for(int y=0;y<image.getHeight(); y+=2){ if(verbose) System.out.println("Block: (" + x+","+y+") -----"); int counter =0; byte [] pixelBytes = new byte[16]; for (int i=0;i<2;i++){ for (int j=0;j<2;j++){ int val = image.getRGB(x+i,y+j); if(trick && encrypt) val +=x*y; byte [] sub = intToByteArray(val); if(verbose){ System.out.println("Val: " + val + " Bytes: ");