Recently I had to help decrypt some AES-ECB and AES-CBC offline. This is straight forward in Python as the cryptographic primitives are provided. LLMs are also very useful to generate code for such tasks.
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
cipher = Cipher(algorithms.AES(key), modes.ECB(), backend=default_backend())
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
decrypted_padded_message = cipher.decryptor().update(encrypted_message) + cipher.decryptor().finalize()
Published on 4 Sep 2024 by Stanley Tan