AES CBC-128 with iv in Python

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

'ETC > Script' 카테고리의 다른 글

Get Alexa Topsites on Alexa  (0) 2019.09.15
Get Verified Phishing url on Phishtank  (0) 2019.09.14
Filescan on Virustotal in Python  (0) 2019.09.14

+ Recent posts