def decryptImage(filename, filepath, passKey, isTripleDES=None):
    """ Decryption for images """

    # Checks if the decryption 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])

        decryptedImageFilename = imageCrypt.decrypt(filename=filename,
                                                    filepath=filepath,
                                                    shifts=(shift1, shift2,
                                                            shift3),
                                                    cipherUsed="TripleDES")

    else:
        shifts = getShiftValuesForImage(passKey=passKey)

        decryptedImageFilename = imageCrypt.decrypt(filename=filename,
                                                    filepath=filepath,
                                                    shifts=shifts,
                                                    cipherUsed="DES")

    return decryptedImageFilename
예제 #2
0
def decryptCheck(passKey, dataformat, cipherMode=None, ciphertext=None, filename=None, filepath=None):
    """ Organises how the different dataformats are decrypted """

    if dataformat == "Messages":
        decryptedData = decryptMessage(ciphertext=ciphertext, passKey=passKey)
        timeTaken = 0

    elif dataformat == "Files":
        if cipherMode == "Base64":
            start = time.time()

            decryptedData = decryptFileBase64(filename=filename, passKey=passKey, filepath=filepath)

            end = time.time()
            timeTaken = end - start

        else:
            start = time.time()

            decryptedData = decryptFile(filename=filename, filepath=filepath, passKey=passKey)

            end = time.time()
            timeTaken = end - start

    elif dataformat == "Images":
        start = time.time()
        shift = getShiftKeyForImage(passKey=passKey)

        decryptedData = imageCrypt.decrypt(filename=filename, filepath=filepath, shifts=shift, cipherUsed="AES")

        end = time.time()
        timeTaken = end - start

    return decryptedData, timeTaken