19 lines
345 B
Python
19 lines
345 B
Python
from Crypto.Cipher import AES
|
|
from Crypto.Util.Padding import unpad
|
|
|
|
# Read Key
|
|
with open('key', 'rb') as f:
|
|
aes_key = f.read()
|
|
|
|
cipher = AES.new(aes_key, AES.MODE_CBC)
|
|
|
|
# Read message and decrypt
|
|
|
|
with open('ctext', 'rb') as f:
|
|
ciphertext = f.read()
|
|
|
|
plaintext = unpad(cipher.decrypt(ciphertext), 16)
|
|
|
|
print(f'Plaintext: {plaintext}')
|
|
|