Python AES Decryption Routine (Code Help)
I developed a code based on information available online regarding an AES Encryption and Decryption routine. Language: Python 2.7.x Complete Code - #!/usr/bin/python import sys,
Solution 1:
You are concatenating a byte string with a Unicode value, triggering an automatic decode of the bytestring. This fails, as your decrypted text is not decodable as ASCII.
Don't use Unicode INTERRUPT
and PAD
values here; you are not reading Unicode data from the file here anyway:
INTERRUPT = '\1'
PAD = '\0'
You'll have to create a new instance of the AES
object to decrypt; you cannot reuse the object you used for encrypting as it's IV state has been altered by the encryption:
decrypt_cipher = AES.new(SECRET, AES.MODE_CBC, IV)
decrypted_data = decAES(decrypt_cipher, data2decrypt)
With those changes your code works and can encrypt and again decrypt the data.
Post a Comment for "Python AES Decryption Routine (Code Help)"