def encryptImage(filename, filepath, passKey, isTripleDES=None): """ Encryption for images """ # Checks if the encryption is done through Triple DES if isTripleDES is True: # In Triple DES, there will be two shift keys shift1 = getShiftValuesForImage(passKey=passKey[0]) shift2 = getShiftValuesForImage(passKey=passKey[1]) shift3 = getShiftValuesForImage(passKey=passKey[2]) encryptedImageFilename = imageCrypt.encrypt(filename=filename, filepath=filepath, shifts=(shift1, shift2, shift3), cipherUsed="TripleDES") else: shifts = getShiftValuesForImage(passKey=passKey) encryptedImageFilename = imageCrypt.encrypt(filename=filename, filepath=filepath, shifts=shifts, cipherUsed="DES") return encryptedImageFilename
def encryptCheck(passKey, dataformat, cipherMode=None, plaintext=None, filename=None, filepath=None): """ Organises how the different dataformats are encrypted """ if dataformat == "Messages": encryptedData = encryptMessage(plaintext=plaintext, passKey=passKey) timeTaken = 0 elif dataformat == "Files": if cipherMode == "Base64": start = time.time() encryptedData = encryptFileBase64(filename=filename, passKey=passKey, filepath=filepath) end = time.time() timeTaken = end - start else: start = time.time() encryptedData = encryptFile(filename=filename, filepath=filepath, passKey=passKey) end = time.time() timeTaken = end - start elif dataformat == "Images": start = time.time() shift = getShiftKeyForImage(passKey=passKey) encryptedData = imageCrypt.encrypt(filename=filename, filepath=filepath, shifts=shift, cipherUsed="AES") end = time.time() timeTaken = end - start return encryptedData, timeTaken