For Encryption
def encrypt(my_key=KEY, my_iv=IV, my_plain_text=PLAIN_TEXT):
key = binascii.unhexlify('ce975de9294067470d1684442555767fcb007c5a3b89927714e449c3f66cb2a4')
iv = binascii.unhexlify('9aaecfcf7e82abb8118d8e567d42ee86')
padder = PKCS7Padder()
padded_text = padder.encode(my_plain_text)
encryptor = AES.new(key, AES.MODE_CBC, iv, segment_size=128) # Initialize encryptor
result = encryptor.encrypt(padded_text)
return {
"plain": my_plain_text,
"key": binascii.hexlify(key),
"iv": binascii.hexlify(iv),
"ciphertext": result
}