diff --git a/index.py b/index.py index 11de23e..653ecd6 100644 --- a/index.py +++ b/index.py @@ -19,9 +19,11 @@ def encrypt(text, key): return cipher_text -def decrypt(): - greet = '\nhello decryption' - return greet +def decrypt(text, key): + # make decrypter + decrypter = AES.new(key, AES.MODE_CFB) + plain_text = decrypter.decrypt(text) + return plain_text def main(): @@ -36,14 +38,20 @@ def main(): # read the text file in and make it a string with no line breaks text = args.file.read().replace('\n', '') + # print encrypted text + print("Original file contents:") + print(text) + # encrypt the file encrypted_text = encrypt(str.encode(text), key) # print encrypted text - print("Encrypted file created. Contents:") + print("\nEncrypted file created. Contents:") print(encrypted_text) - print(decrypt()) + # decrypt and print decrypted text + print("\nDecrypted file. Contents:") + print(decrypt(encrypted_text, key)) if __name__ == '__main__':