ETC/Script

AES CBC-128 with iv in Python

0xe82de_ 2019. 8. 21. 20:30
728x90
728x90
728x90
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad

#key, iv 16bytes
key = '000102030405060708090a0b0c0d0e0f'
iv = '000102030405060708090a0b0c0d0e0f'

print('key => ', key)
print('iv  => ', iv)

p = input('\nEnter plaintext : ')
print('\nyour plaintext => ', p)

cipher = AES.new(bytes.fromhex(key), AES.MODE_CBC, bytes.fromhex(iv))
c = cipher.encrypt(pad(p.encode(), AES.block_size))
print('encrypted text => ', c.hex())

cipher = AES.new(bytes.fromhex(key), AES.MODE_CBC, bytes.fromhex(iv))
d = unpad(cipher.decrypt(c), AES.block_size)
print('decrypted text => ', d.decode())

 

 

AES Online #1 : https://gchq.github.io/CyberChef/

 

CyberChef

 

gchq.github.io

AES Online #2 : https://cryptii.com/

 

Modular conversion, encoding and encryption online

Web app offering modular conversion, encoding and encryption online. Translations are done in the browser without any server interaction. This is an Open Source project, code licensed MIT.

cryptii.com

 

728x90
728x90