def performArnoldShuffle(): filePath = entry1.get() #print(filename) fileNameArr = filePath.split("/") fileName = fileNameArr[len(fileNameArr) - 1] print(fileName) absFilePath = os.path.abspath(fileName) print(absFilePath) mapList = gam.driverProgram() imageMatrix = gam.cim.getImageMatrix(absFilePath) resImage = gam.createArnoldCatImage(imageMatrix, mapList) entry2.insert(0, resImage)
def arnoldDeBuilder(parted, fileName="aaa"): arnoldList = [] ss = 1 for part in parted: width = len(part) height = len(part[0]) if width == 1: arnoldList.append(part) print("{}/{}: {}x{}".format(ss, len(parted), width, height)) modN = width numberOfIterations = args.numberOfIterations mapList = gam.driverProgram(width, height, numberOfIterations, modN) resImage = aD.decryptArnoldImage(part, mapList, width, fileName + "-a" + str(ss)) arnoldList.append(resImage) ss += 1 return arnoldList
def arnoldEnBuilder(parted, fileName="aaa"): arnoldList = [] ss = 1 for part in parted: a_time = time.time() width = len(part) height = len(part[0]) print("{}/{}: {}x{}".format(ss, len(parted), width, height)) modN = width numberOfIterations = args.numberOfIterations mapList = gam.driverProgram(width, height, numberOfIterations, modN) resImage = gam.createArnoldCatImage(part, mapList, width, fileName + "-a" + str(ss)) arnoldList.append(resImage) ss += 1 print(' {}'.format(time.time() - a_time)) return arnoldList
def performArnoldShuffle(): filePath = entry1.get() #print(filename) fileNameArr = filePath.split("/") fileName = fileNameArr[len(fileNameArr) - 1] print(fileName) absFilePath = os.path.abspath(fileName) print(absFilePath) im = Image.open(absFilePath) image_size = im.size width = image_size[0] height = image_size[1] numberOfIterations = int(entry5.get()) modN = int(entry6.get()) mapList = gam.driverProgram(width, height, numberOfIterations, modN) imageMatrix = gam.cim.getImageMatrix(absFilePath) resImage = gam.createArnoldCatImage(imageMatrix, mapList, width, height) entry2.insert(0, resImage)
def decryptArnoldImage(width, height, numberOfIterations, modN, imageName): im = Image.open(imageName) image_size = im.size width = image_size[0] height = image_size[1] mapList = gam.driverProgram(width, height, numberOfIterations, modN) print(mapList) henonDecryptedImage = cim.getImageMatrix(imageName) print(henonDecryptedImage) arnoldDecryptedImage = [] for i in range(width): row = [] for j in range(height): try: row.append((0)) except: row = [(0)] try: arnoldDecryptedImage.append(row) except: arnoldDecryptedImage = [row] for map in mapList: for key, value in map.items(): print(key[0], key[1], value[0], value[1]) arnoldDecryptedImage[key[0]][key[1]] = (henonDecryptedImage[int( value[0])][int(value[1])]) im = Image.new("L", (width, height)) pix = im.load() for x in range(width): for y in range(height): pix[x, y] = arnoldDecryptedImage[x][y] im.save("ArnoldDecryptedImage.bmp", "BMP") return os.path.abspath("ArnoldDecryptedImage.bmp")