├── test.bmp ├── lena_gray.bmp ├── EncryptionProcess.png ├── ImageEncryptionUI.png ├── ArnoldDecryptedImage.bmp ├── HenonDecryptedImage.bmp ├── HenonTransformedImage.bmp ├── createImageMatrix.py ├── README.md ├── HenonDecryption.py ├── ArnoldDecryption.py ├── ImageTransformation.py ├── generateHenonMap.py ├── Image Encryption UI.py ├── generateArnoldMap.py ├── Image Decryption UI.py └── ImageEncryptionUI.py /test.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manishjathan/Image-Encryption-Using-Chaotic-Map/HEAD/test.bmp -------------------------------------------------------------------------------- /lena_gray.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manishjathan/Image-Encryption-Using-Chaotic-Map/HEAD/lena_gray.bmp -------------------------------------------------------------------------------- /EncryptionProcess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manishjathan/Image-Encryption-Using-Chaotic-Map/HEAD/EncryptionProcess.png -------------------------------------------------------------------------------- /ImageEncryptionUI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manishjathan/Image-Encryption-Using-Chaotic-Map/HEAD/ImageEncryptionUI.png -------------------------------------------------------------------------------- /ArnoldDecryptedImage.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manishjathan/Image-Encryption-Using-Chaotic-Map/HEAD/ArnoldDecryptedImage.bmp -------------------------------------------------------------------------------- /HenonDecryptedImage.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manishjathan/Image-Encryption-Using-Chaotic-Map/HEAD/HenonDecryptedImage.bmp -------------------------------------------------------------------------------- /HenonTransformedImage.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manishjathan/Image-Encryption-Using-Chaotic-Map/HEAD/HenonTransformedImage.bmp -------------------------------------------------------------------------------- /createImageMatrix.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | 3 | 4 | def getImageMatrix(imageName): 5 | im = Image.open(imageName) 6 | pix = im.load() 7 | image_size = im.size #Get the width and hight of the image for iterating over 8 | print("Image Size : ",image_size) 9 | image_matrix = [] 10 | for width in range(int(image_size[0])): 11 | row = [] 12 | for height in range(int(image_size[1])): 13 | try: 14 | #Getting only the blue pixels 15 | row.append((pix[width,height])) 16 | except: 17 | row=[pix[width, height]] 18 | try: 19 | image_matrix.append(row) 20 | except: 21 | image_matrix = [row] 22 | 23 | file = open("ImageMatrix.csv","w") 24 | file.write(str(image_matrix)) 25 | file.close() 26 | return image_matrix 27 | 28 | 29 | #imageMatrix = getImageMatrix() 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Image-Encryption-Using-Chaotic-Map 2 | * Image Encryption using Arnold Cat Map and Henon Map. 3 | * Process is Arnold Cat Map followed by Henon Map and reverse for decryption. 4 | * Henon key values used are x=0.1,y=0.1 5 | 6 | ## Steps to Encrypt 7 | * Run ImageEncryption UI.py for encrypting an image 8 | * Place the image path under the select image label. 9 | * Enter the Number of iterations for the arnold cat map shuffling along with value of n in Mod n. 10 | * One can select either of the two buttons "Generate Arnold Cat Map" or "Generate Henon Map" 11 | * Or click on perform encryption. 12 | * Full image file path appears in the text box next to the buttons. 13 | 14 | ## Steps to Decrypt 15 | * Run Image Decryption UI.py for decrypting an image. 16 | * Follow steps similar to encryption but in reverse order. 17 | 18 | ### Image Encryption UI 19 | ![Image Encryption UI](ImageEncryptionUI.png) 20 |
21 |
22 | ### Encrypted Images 23 | * Input Image 24 | * Arnold Cat Image 25 | * Henon Map Image 26 | ![Encryption Process](EncryptionProcess.png) 27 | -------------------------------------------------------------------------------- /HenonDecryption.py: -------------------------------------------------------------------------------- 1 | #Input : Henon Encrypted Image 2 | #Processing: 3 | #get pixel values of Henon Encrypted Image 4 | #Ex-Or with Henon generated Matrix 5 | #Output : Henon Decrypted Image 6 | 7 | import createImageMatrix as cim 8 | import generateHenonMap as ghm 9 | from PIL import Image 10 | import os 11 | 12 | def decryptHenonImage(imageName): 13 | imageMatrix = cim.getImageMatrix(imageName) 14 | transformationMatrix = ghm.genTransformationMatrix(len(imageMatrix)) 15 | 16 | henonDecryptedImage = [] 17 | for i in range(len(imageMatrix)): 18 | row = [] 19 | for j in range(len(imageMatrix)): 20 | try: 21 | row.append(imageMatrix[i][j] ^ transformationMatrix[i][j]) 22 | except: 23 | row = [imageMatrix[i][j] ^ transformationMatrix[i][j]] 24 | 25 | try: 26 | henonDecryptedImage.append(row) 27 | except: 28 | henonDecryptedImage = [row] 29 | 30 | width = len(imageMatrix[0]) 31 | height = len(imageMatrix) 32 | 33 | im = Image.new("L", (width, height)) 34 | pix = im.load() 35 | for x in range(width): 36 | for y in range(height): 37 | pix[x, y] = henonDecryptedImage[x][y] 38 | im.save("HenonDecryptedImage.bmp", "BMP") 39 | #return henonDecryptedImage 40 | return os.path.abspath("HenonDecryptedImage.bmp") 41 | -------------------------------------------------------------------------------- /ArnoldDecryption.py: -------------------------------------------------------------------------------- 1 | import generateArnoldMap as gam 2 | import createImageMatrix as cim 3 | from PIL import Image 4 | import os 5 | 6 | def decryptArnoldImage(width,height,numberOfIterations,modN,imageName): 7 | 8 | im = Image.open(imageName) 9 | image_size = im.size 10 | width = image_size[0] 11 | height = image_size[1] 12 | 13 | mapList = gam.driverProgram(width,height,numberOfIterations,modN) 14 | print(mapList) 15 | henonDecryptedImage = cim.getImageMatrix(imageName) 16 | print(henonDecryptedImage) 17 | arnoldDecryptedImage = [] 18 | 19 | 20 | for i in range(width): 21 | row = [] 22 | for j in range(height): 23 | try: 24 | row.append((0)) 25 | except: 26 | row = [(0)] 27 | try: 28 | arnoldDecryptedImage.append(row) 29 | except: 30 | arnoldDecryptedImage = [row] 31 | 32 | for map in mapList: 33 | for key,value in map.items(): 34 | print(key[0],key[1],value[0],value[1]) 35 | arnoldDecryptedImage[key[0]][key[1]] = (henonDecryptedImage[int(value[0])][int(value[1])]) 36 | 37 | im = Image.new("L", (width, height)) 38 | pix = im.load() 39 | for x in range(width): 40 | for y in range(height): 41 | pix[x, y] = arnoldDecryptedImage[x][y] 42 | im.save("ArnoldDecryptedImage.bmp", "BMP") 43 | return os.path.abspath("ArnoldDecryptedImage.bmp") 44 | 45 | #decryptArnoldImage("C:/Users/capiot/PycharmProjects/ImageEncryption/HenonDecryptedImage.bmp") 46 | -------------------------------------------------------------------------------- /ImageTransformation.py: -------------------------------------------------------------------------------- 1 | import generateHenonMap as ghm 2 | from PIL import Image 3 | import os 4 | 5 | def pixelManipulation(size,imageName): 6 | imageMatrix = ghm.getImageMatrix(imageName) 7 | #for line in imageMatrix: 8 | # print(line) 9 | print("ImageMatrix Rows : %d Cols : %d " % (len(imageMatrix), len(imageMatrix[0]))) 10 | transformationMatrix = ghm.genTransformationMatrix(size) 11 | #for line in transformationMatrix: 12 | # print(line) 13 | print("Transformation Matrix Rows : %d Cols : %d" %(len(transformationMatrix),len(transformationMatrix[0]))) 14 | 15 | #Performing Ex-Or Operation between the transformation Matrix and ImageMatrix 16 | #Storing the result in resultant Matrix 17 | resultantMatrix = [] 18 | for i in range(size): 19 | row = [] 20 | for j in range(size): 21 | try: 22 | row.append(transformationMatrix[i][j] ^ imageMatrix[i][j]) 23 | except: 24 | row = [transformationMatrix[i][j] ^ imageMatrix[i][j]] 25 | try: 26 | resultantMatrix.append(row) 27 | except: 28 | resultantMatrix = [row] 29 | 30 | print("Pixel Manipulated Values : ") 31 | for rows in resultantMatrix: 32 | print(rows) 33 | 34 | # mode = "L", here mode L stands for black and white and Size = "512 * 512" 35 | #Creating Henon Transformed Image from resultant matrix 36 | im = Image.new("L", (size, size)) 37 | pix = im.load() 38 | for x in range(size): 39 | for y in range(size): 40 | pix[x, y] = resultantMatrix[x][y] 41 | im.save("HenonTransformedImage.bmp", "BMP") 42 | absPath = os.path.abspath("HenonTransformedImage.bmp") 43 | return absPath 44 | 45 | #pixelManipulation(512,"test.bmp") -------------------------------------------------------------------------------- /generateHenonMap.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | 3 | def getImageMatrix(image): 4 | im = Image.open(image) # Can be many different formats. 5 | pix = im.load() 6 | image_size = im.size #Get the width and hight of the image for iterating over 7 | print("Image Size : ",image_size) 8 | image_matrix = [] 9 | for width in range(int(image_size[0])): 10 | row = [] 11 | for height in range(int(image_size[1])): 12 | try: 13 | #Getting only the blue pixels 14 | row.append((pix[width,height])) 15 | except: 16 | row=[pix[width, height]] 17 | try: 18 | image_matrix.append(row) 19 | except: 20 | image_matrix = [row] 21 | # Not able to perform file operations when imported into another module 22 | #file = open("LenaImageMatrix.csv","w") 23 | #file.write(str(image_matrix)) 24 | #file.close() 25 | return image_matrix 26 | 27 | 28 | def dec(bitSequence): 29 | decimal = 0 30 | for bit in bitSequence: 31 | decimal = decimal * 2 + int(bit) 32 | return decimal 33 | 34 | 35 | #Takes size of the image as an input 36 | def genTransformationMatrix(m): 37 | #Replace Hardcoded Pixel Values 38 | #Serves as the initial Parameter and also the symmetric secret key 39 | x = 0.1 40 | y = 0.1 41 | sequenceSize = m * m * 8 #Total Number of bitSequence produced 42 | bitSequence = [] #Each bitSequence contains 8 bits 43 | byteArray = [] #Each byteArray contains m( i.e 512 in this case) bitSequence 44 | TImageMatrix = [] #Each TImageMatrix contains m*n byteArray( i.e 512 byteArray in this case) 45 | for i in range(sequenceSize): 46 | #Henon Map formula 47 | xN = y + 1 - 1.4 * x**2 48 | yN = 0.3 * x 49 | 50 | # New x = xN and y = yN 51 | x = xN 52 | y = yN 53 | 54 | # Each Value of xN is converted into 0 or 1 based on the threshold value 55 | if xN <= 0.3992: 56 | bit = 0 57 | else: 58 | bit = 1 59 | #bits are inserted into bitSequence 60 | try: 61 | bitSequence.append(bit) 62 | except: 63 | bitSequence = [bit] 64 | #Each bitSequence is converted into a decimal number 65 | #This decimal number is inserted into byteArray 66 | if i % 8 == 7: 67 | decimal = dec(bitSequence) 68 | try: 69 | byteArray.append(decimal) 70 | except: 71 | byteArray = [decimal] 72 | print(bitSequence,decimal) 73 | bitSequence = [] 74 | #ByteArray is inserted into TImageMatrix 75 | byteArraySize = m*8 76 | if i % byteArraySize == byteArraySize-1: 77 | print(byteArray) 78 | try: 79 | TImageMatrix.append(byteArray) 80 | except: 81 | TImageMatrix = [byteArray] 82 | print(len(byteArray),byteArray) 83 | byteArray = [] 84 | 85 | #TImageMatrix is written into below FIle 86 | # Not able to perform file operations when imported into another module 87 | #file = open("LenaTranformationMatrix.csv", "w") 88 | #file.write(str(TImageMatrix)) 89 | #file.close() 90 | return TImageMatrix 91 | 92 | -------------------------------------------------------------------------------- /Image Encryption UI.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import filedialog 3 | import os 4 | import generateArnoldMap as gam 5 | import ImageTransformation as iT 6 | from PIL import ImageTk, Image 7 | 8 | def choose_File(): 9 | filename = filedialog.askopenfilename() 10 | entry1.insert(0,str(filename)) 11 | 12 | def performArnoldShuffle(): 13 | filePath = entry1.get() 14 | #print(filename) 15 | fileNameArr = filePath.split("/") 16 | fileName = fileNameArr[len(fileNameArr)-1] 17 | print(fileName) 18 | absFilePath = os.path.abspath(fileName) 19 | print(absFilePath) 20 | 21 | mapList = gam.driverProgram() 22 | imageMatrix = gam.cim.getImageMatrix(absFilePath) 23 | resImage = gam.createArnoldCatImage(imageMatrix,mapList) 24 | entry2.insert(0,resImage) 25 | 26 | 27 | def performHenonManipulation(): 28 | filename = entry1.get() 29 | resImage = iT.pixelManipulation(512, filename) 30 | entry3.insert(0,resImage) 31 | #print(filename) 32 | 33 | def performEntireEncryption(): 34 | performArnoldShuffle() 35 | filename = entry2.get() 36 | resImage = iT.pixelManipulation(512, filename) 37 | entry3.insert(0, resImage) 38 | entry4.insert(0, resImage) 39 | 40 | 41 | def openFileForArnold(): 42 | window = Toplevel(root) 43 | window.title("Arnold Map") 44 | window.geometry("600x600") 45 | path = entry2.get() 46 | img = ImageTk.PhotoImage(Image.open(path)) 47 | panel = Label(window, image=img) 48 | panel.pack(side="bottom", fill="both", expand="yes") 49 | window.mainloop() 50 | 51 | def openFileForHenon(): 52 | window = Toplevel(root) 53 | window.title("Henon Map") 54 | window.geometry("600x600") 55 | path = entry3.get() 56 | img = ImageTk.PhotoImage(Image.open(path)) 57 | panel = Label(window, image=img) 58 | panel.pack(side="bottom", fill="both", expand="yes") 59 | window.mainloop() 60 | 61 | #from tkFileDialog import askopenfilename 62 | 63 | root =Tk() 64 | topFrame = Frame(root) 65 | topFrame.pack() 66 | 67 | middleFrame = Frame(root) 68 | middleFrame.pack(side=BOTTOM) 69 | 70 | bottomFrame = Frame(root) 71 | bottomFrame.pack(side=BOTTOM) 72 | 73 | encryptionFrame = Frame(root) 74 | encryptionFrame.pack(side=BOTTOM) 75 | 76 | label_1 = Label(topFrame, text ="Image to be Encrypted : ",width = 125) 77 | entry1 = Entry(topFrame,width =100) 78 | button1 = Button(topFrame, text = "Select Image",command = choose_File) 79 | 80 | button2 = Button(middleFrame, text = "Generate Arnold Cat Map",command = performArnoldShuffle,width=20) 81 | entry2 = Entry(middleFrame,width =80) 82 | button3 = Button(middleFrame, text="Open Image",command = openFileForArnold) 83 | 84 | button4 = Button(bottomFrame, text="Generate Henon Map",command = performHenonManipulation,width=20) 85 | entry3 = Entry(bottomFrame,width =80) 86 | button5 = Button(bottomFrame, text="Open Image",command = openFileForHenon) 87 | 88 | button6 = Button(encryptionFrame, text="Perform Encryption",command = performEntireEncryption,width=20) 89 | entry4 = Entry(encryptionFrame,width=80) 90 | button7 = Button(encryptionFrame, text="Open Image",command = openFileForHenon) 91 | 92 | label_1.pack(side = TOP) 93 | entry1.pack(side = TOP) 94 | button1.pack(side = TOP) 95 | 96 | 97 | button2.pack(side = LEFT) 98 | entry2.pack(side=LEFT) 99 | button3.pack(side=LEFT) 100 | 101 | button4.pack(side = LEFT) 102 | entry3.pack(side = LEFT) 103 | button5.pack(side = LEFT) 104 | 105 | button6.pack(side = LEFT) 106 | entry4.pack(side =LEFT) 107 | button7.pack(side=LEFT) 108 | 109 | root.mainloop() -------------------------------------------------------------------------------- /generateArnoldMap.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import createImageMatrix as cim 3 | import numpy as np 4 | import os 5 | 6 | def multiplyMatrix(A,B,res): 7 | if len(A[0]) == len(B): 8 | for i in range(len(A)): 9 | for j in range(len(B[0])): 10 | for k in range(len(A[0])): 11 | res[i][j] = res[i][j] + A[i][k]*B[k][j] 12 | return res 13 | 14 | def matrixModulo(inputMatrix,n): 15 | newMatrix = [] 16 | for row in inputMatrix: 17 | newRow= [] 18 | for el in row: 19 | newEl = el%n 20 | try: 21 | newRow.append(newEl) 22 | except: 23 | newRow = [newEl] 24 | try: 25 | newMatrix.append(newRow) 26 | except: 27 | newMatrix = [newRow] 28 | return newMatrix 29 | 30 | def genArnoldMap(res,inputMatrix,numberOfIterations,modN): 31 | map = {} 32 | res1 = np.zeros(shape = (2,1)) 33 | res1 = matrixModulo(multiplyMatrix(res,inputMatrix,res1),modN) 34 | count = 0 35 | while (res1 != inputMatrix) and (count < numberOfIterations): 36 | res2 = np.zeros(shape = (2,1)) 37 | res1 = matrixModulo(multiplyMatrix(res,res1,res2),modN) 38 | count += 1 39 | newtuple = (res1[0][0],res1[1][0]) 40 | actualtuple = (inputMatrix[0][0],inputMatrix[1][0]) 41 | map[actualtuple] = newtuple 42 | #print(map) 43 | return map 44 | 45 | def driverProgram(width,height,numberOfIterations,modN): 46 | n = 2 47 | mapList = [] 48 | UTM = np.triu(np.ones((n,n),dtype = int),0) 49 | LTM = np.tril(np.ones((n,n),dtype = int),0) 50 | RM = np.zeros(shape = (n,n)) 51 | res = multiplyMatrix(LTM,UTM,RM) 52 | #print(res) 53 | for i in range(width): 54 | for j in range(height): 55 | inputMatrix = [[i],[j]] 56 | map = genArnoldMap(res,inputMatrix,numberOfIterations,modN) 57 | try: 58 | mapList.append(map) 59 | except: 60 | mapList = [map] 61 | #print(mapList) 62 | return mapList 63 | 64 | def createArnoldCatImage(imageMatrix,mapList,width,height): 65 | arnoldImageMatrix = [] 66 | #Creating a zero matrix for arnold Cat map 67 | for i in range(width): 68 | row = [] 69 | for j in range(height): 70 | try: 71 | row.append((0)) 72 | except: 73 | row = [(0)] 74 | try: 75 | arnoldImageMatrix.append(row) 76 | except: 77 | arnoldImageMatrix = [row] 78 | 79 | #Inserting pixel values into arnold Cat Image Matrix 80 | for map in mapList: 81 | for keys in map.keys(): 82 | #print(imageMatrix[keys[0]][keys[1]],int(map[keys][0]),int(map[keys][1])) 83 | arnoldImageMatrix[int(map[keys][0])][int(map[keys][1])] = (imageMatrix[keys[0]][keys[1]]) 84 | 85 | #print(arnoldImageMatrix) 86 | file = open("ArnoldImageMatrix.csv", "w") 87 | file.write(str(arnoldImageMatrix)) 88 | file.close() 89 | 90 | im = Image.new("L", (width, height)) 91 | pix = im.load() 92 | for x in range(width): 93 | for y in range(height): 94 | pix[x, y] = arnoldImageMatrix[x][y] 95 | im.save("test.bmp", "BMP") 96 | absPath = os.path.abspath("test.bmp") 97 | return absPath 98 | 99 | #mapList = driverProgram() 100 | #imageMatrix = cim.getImageMatrix("C:\\Users\\capiot\\PycharmProjects\\ImageEncryption\\lena_gray.bmp") 101 | #resImage = createArnoldCatImage(imageMatrix,mapList) 102 | #print(resImage) 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /Image Decryption UI.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import filedialog 3 | import os 4 | import HenonDecryption as hD 5 | import ArnoldDecryption as aD 6 | from PIL import ImageTk, Image 7 | 8 | def choose_File(): 9 | filename = filedialog.askopenfilename() 10 | entry1.insert(0,str(filename)) 11 | 12 | def decryptArnoldShuffle(): 13 | filePath = entry1.get() 14 | 15 | im = Image.open(filePath) 16 | image_size = im.size 17 | 18 | width = image_size[0] 19 | height = image_size[1] 20 | 21 | numberOfIterations = int(entry5.get()) 22 | modN = int(entry6.get()) 23 | 24 | resImage = aD.decryptArnoldImage(width,height,numberOfIterations,modN,filePath) 25 | entry2.insert(0,resImage) 26 | 27 | 28 | def decryptHenonManipulation(): 29 | filename = entry1.get() 30 | resImage = hD.decryptHenonImage(filename) 31 | entry3.insert(0,resImage) 32 | #print(filename) 33 | 34 | def performEntireDecryption(): 35 | hD.decryptHenonImage() 36 | filename = entry3.get() 37 | resImage = aD.decryptArnoldImage(filename) 38 | entry2.insert(0, resImage) 39 | entry4.insert(0, resImage) 40 | 41 | 42 | def openFileForArnold(): 43 | window = Toplevel(root) 44 | window.title("Arnold Map") 45 | window.geometry("600x600") 46 | path = entry2.get() 47 | img = ImageTk.PhotoImage(Image.open(path)) 48 | panel = Label(window, image=img) 49 | panel.pack(side="bottom", fill="both", expand="yes") 50 | window.mainloop() 51 | 52 | def openFileForHenon(): 53 | window = Toplevel(root) 54 | window.title("Henon Map") 55 | window.geometry("600x600") 56 | path = entry3.get() 57 | img = ImageTk.PhotoImage(Image.open(path)) 58 | panel = Label(window, image=img) 59 | panel.pack(side="bottom", fill="both", expand="yes") 60 | window.mainloop() 61 | 62 | #from tkFileDialog import askopenfilename 63 | 64 | root =Tk() 65 | Frame1 = Frame(root) 66 | Frame1.pack() 67 | 68 | Frame2 = Frame(root) 69 | Frame2.pack(side=TOP) 70 | 71 | Frame3 = Frame(root) 72 | Frame3.pack(side=TOP) 73 | 74 | Frame4= Frame(root) 75 | Frame4.pack(side=TOP) 76 | 77 | Frame5 = Frame(root) 78 | Frame5.pack(side = TOP) 79 | 80 | label_1 = Label(Frame1, text ="Image to be Decrypted : ",width = 125) 81 | entry1 = Entry(Frame1,width =100) 82 | button1 = Button(Frame1, text = "Select Image",command = choose_File) 83 | 84 | label_2 = Label(Frame2,text = "No. Of Iterations:") 85 | entry5 = Entry(Frame2,width = 80) 86 | 87 | label_3 = Label(Frame2,text = "Value of mod N:") 88 | entry6 = Entry(Frame2,width = 80) 89 | 90 | button2 = Button(Frame3, text = "Decrypt Arnold Cat Map",command = decryptArnoldShuffle,width=20) 91 | entry2 = Entry(Frame3,width =80) 92 | button3 = Button(Frame3, text="Open Image",command = openFileForArnold) 93 | 94 | button4 = Button(Frame4, text="Decrypt Henon Map",command = decryptHenonManipulation,width=20) 95 | entry3 = Entry(Frame4,width =80) 96 | button5 = Button(Frame4, text="Open Image",command = openFileForHenon) 97 | 98 | button6 = Button(Frame5, text="Perform Decryption",command = performEntireDecryption,width=20) 99 | entry4 = Entry(Frame5,width=80) 100 | button7 = Button(Frame5, text="Open Image",command = openFileForArnold) 101 | 102 | label_1.pack(side = TOP) 103 | entry1.pack(side = TOP) 104 | button1.pack(side = TOP) 105 | 106 | label_2.pack(side = TOP) 107 | entry5.pack(side = TOP) 108 | 109 | label_3.pack(side = TOP) 110 | entry6.pack(side =TOP) 111 | 112 | button2.pack(side = LEFT) 113 | entry2.pack(side=LEFT) 114 | button3.pack(side=LEFT) 115 | 116 | button4.pack(side = LEFT) 117 | entry3.pack(side = LEFT) 118 | button5.pack(side = LEFT) 119 | 120 | button6.pack(side = LEFT) 121 | entry4.pack(side =LEFT) 122 | button7.pack(side=LEFT) 123 | 124 | root.mainloop() -------------------------------------------------------------------------------- /ImageEncryptionUI.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import filedialog 3 | import os 4 | import generateArnoldMap as gam 5 | import ImageTransformation as iT 6 | from PIL import ImageTk, Image 7 | 8 | def choose_File(): 9 | filename = filedialog.askopenfilename() 10 | entry1.insert(0,str(filename)) 11 | 12 | def performArnoldShuffle(): 13 | filePath = entry1.get() 14 | #print(filename) 15 | fileNameArr = filePath.split("/") 16 | fileName = fileNameArr[len(fileNameArr)-1] 17 | print(fileName) 18 | absFilePath = os.path.abspath(fileName) 19 | print(absFilePath) 20 | 21 | im = Image.open(absFilePath) 22 | image_size = im.size 23 | 24 | width = image_size[0] 25 | height = image_size[1] 26 | 27 | numberOfIterations = int(entry5.get()) 28 | modN = int(entry6.get()) 29 | 30 | mapList = gam.driverProgram(width,height,numberOfIterations,modN) 31 | imageMatrix = gam.cim.getImageMatrix(absFilePath) 32 | resImage = gam.createArnoldCatImage(imageMatrix,mapList,width,height) 33 | entry2.insert(0,resImage) 34 | 35 | def performHenonManipulation(): 36 | filename = entry1.get() 37 | resImage = iT.pixelManipulation(512, filename) 38 | entry3.insert(0,resImage) 39 | #print(filename) 40 | 41 | def performEntireEncryption(): 42 | performArnoldShuffle() 43 | filename = entry2.get() 44 | resImage = iT.pixelManipulation(512, filename) 45 | entry3.insert(0, resImage) 46 | entry4.insert(0, resImage) 47 | 48 | 49 | def openFileForArnold(): 50 | window = Toplevel(root) 51 | window.title("Arnold Map") 52 | window.geometry("600x600") 53 | path = entry2.get() 54 | img = ImageTk.PhotoImage(Image.open(path)) 55 | panel = Label(window, image=img) 56 | panel.pack(side="bottom", fill="both", expand="yes") 57 | window.mainloop() 58 | 59 | def openFileForHenon(): 60 | window = Toplevel(root) 61 | window.title("Henon Map") 62 | window.geometry("600x600") 63 | path = entry3.get() 64 | img = ImageTk.PhotoImage(Image.open(path)) 65 | panel = Label(window, image=img) 66 | panel.pack(side="bottom", fill="both", expand="yes") 67 | window.mainloop() 68 | 69 | #from tkFileDialog import askopenfilename 70 | 71 | root =Tk() 72 | Frame1 = Frame(root) 73 | Frame1.pack() 74 | 75 | Frame2 = Frame(root) 76 | Frame2.pack(side=TOP) 77 | 78 | Frame3 = Frame(root) 79 | Frame3.pack(side=TOP) 80 | 81 | Frame4 = Frame(root) 82 | Frame4.pack(side =TOP) 83 | 84 | Frame5 = Frame(root) 85 | Frame5.pack(side=TOP) 86 | 87 | label_1 = Label(Frame1, text ="Image to be Encrypted : ",width = 125) 88 | entry1 = Entry(Frame1,width =100) 89 | button1 = Button(Frame1, text = "Select Image",command = choose_File) 90 | 91 | label_2 = Label(Frame2,text = "No. Of Iterations:") 92 | entry5 = Entry(Frame2,width = 80) 93 | 94 | label_3 = Label(Frame2,text = "Value of mod N:") 95 | entry6 = Entry(Frame2,width = 80) 96 | 97 | button2 = Button(Frame3, text = "Generate Arnold Cat Map",command = performArnoldShuffle,width=20) 98 | entry2 = Entry(Frame3,width =80) 99 | button3 = Button(Frame3, text="Open Image",command = openFileForArnold) 100 | 101 | button4 = Button(Frame4, text="Generate Henon Map",command = performHenonManipulation,width=20) 102 | entry3 = Entry(Frame4,width =80) 103 | button5 = Button(Frame4, text="Open Image",command = openFileForHenon) 104 | 105 | button6 = Button(Frame5, text="Perform Encryption",command = performEntireEncryption,width=20) 106 | entry4 = Entry(Frame5,width=80) 107 | button7 = Button(Frame5, text="Open Image",command = openFileForHenon) 108 | 109 | label_1.pack(side = TOP) 110 | entry1.pack(side = TOP) 111 | button1.pack(side = TOP) 112 | 113 | label_2.pack(side = TOP) 114 | entry5.pack(side = TOP) 115 | 116 | label_3.pack(side = TOP) 117 | entry6.pack(side =TOP) 118 | 119 | button2.pack(side = LEFT) 120 | entry2.pack(side=LEFT) 121 | button3.pack(side=LEFT) 122 | 123 | button4.pack(side = LEFT) 124 | entry3.pack(side = LEFT) 125 | button5.pack(side = LEFT) 126 | 127 | button6.pack(side = LEFT) 128 | entry4.pack(side =LEFT) 129 | button7.pack(side=LEFT) 130 | 131 | root.mainloop() --------------------------------------------------------------------------------