Created
June 1, 2022 20:56
-
-
Save skelsec/5308609fec2872c0f418acebdbddf554 to your computer and use it in GitHub Desktop.
AES CFB ENC-DEC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Cryptodome.Cipher import AES | |
from Cryptodome.Random import get_random_bytes | |
from pypykatz.commons.common import hexdump | |
data = b"secret" | |
key = b'\xAA'*16 | |
iv = b'\xAA'*16 | |
cipher = AES.new(key, AES.MODE_CFB, iv=iv) | |
ct_bytes = cipher.encrypt(data) | |
print('============ ENCRYPTION ============') | |
print('DATA:') | |
print(hexdump(data)) | |
print('IV:') | |
print(hexdump(iv)) | |
print('KEY') | |
print(hexdump(key)) | |
print('ENC DATA') | |
print(hexdump(ct_bytes)) | |
################################################# | |
dec_iv = b'\xAA'*16 | |
dec_key = b'\xAA'*16 | |
print('============ DECRYPTION ============') | |
print('ENC DATA') | |
print(hexdump(ct_bytes)) | |
print('IV:') | |
print(hexdump(dec_iv)) | |
print('KEY') | |
print(hexdump(dec_key)) | |
cipher = AES.new(dec_key, AES.MODE_CFB, iv=dec_iv) | |
data_dec = cipher.decrypt(ct_bytes) | |
print('DEC DATA') | |
print(hexdump(data_dec)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment