I seem to have misunderstood something about the way Crypto.Cipher is supposed to work, because I'm getting unexpected results, here is my code..
import hashlib
from Crypto.Cipher import AES
from Crypto import Random
h = hashlib.new('sha256')
h.update('my key')
key = h.digest()
iv = Random.new().read(AES.block_size)
cipher = AES.new(key, AES.MODE_CFB, iv)
txt = 'hello world'
This is the part where I'm confused, because it seems like encrypt will output a different result every time, so how can I decrypt it?
msg = cipher.encrypt(txt)
>>> '|sx08xf2x12xdex8cDxe7u*'
msg = cipher.encrypt(txt)
>>> 'xa1xed7xb8h