>>> bs = AES.block_size
>>> pad = lambda s: s + (bs - len(s) % bs) * chr(bs - len(s) % bs)
>>> key = "password1234".encode() # to bytes
>>> aes_1 = AES.new(md5(key).digest(), AES.MODE_CFB, bytes([random.randint(0,0 xFF) for i in range(16)]))
>>> aes_2 = AES.new(md5(key).digest(), AES.MODE_CFB, bytes([random.randint(0,0 xFF) for i in range(16)]))
>>> d_text = pad("texttexttexttext blablablah")
>>> e_text = aes_1.encrypt(d_text)
>>> aes_1.decrypt(e_text)
b'\n\xce\x85\xeb\x8aK-\xd6\xbe\x9e\xafj;\xf9\x1e. blablablah\x05\x05\x05\x05\x05'
>>> aes_2.decrypt(e_text)
b texttexttexttext blablablah\x05\x05\x05\x05\x05'
Find more questions by tags AESPythonCryptography
>>> iv
b J\x98\x9a\xa7\x92\part no xb8\x0f\xde\x89\x9cZt\xb6\x991\xe5'
>>> aes_1.IV = iv
>>> aes_2.IV = iv
>>> e_text = aes_1.encrypt(d_text)
>>> aes_1.decrypt(e_text)
b'(\x03\xaaB\xb5r?ot%B.\xa0\xf4u% blablablah\x05\x05\x05\x05\x05'
>>> aes_1.IV = iv
>>> aes_1.decrypt(e_text)
b'(\x03\xaaB\xb5r?ot%B.\xa0\xf4u% blablablah\x05\x05\x05\x05\x05'
>>> aes_2.IV == aes_1.IV
True
>>> aes_2.decrypt(e_text)
b texttexttexttext blablablah\x05\x05\x05\x05\x05'
>>> aes_2.decrypt(e_text)
b'(\x03\xaaB\xb5r?ot%B.\xa0\xf4u% blablablah\x05\x05\x05\x05\x05'
>>> aes_2.IV == aes_1.IV
True
>>> aes_1.decrypt(e_text)
b'(\x03\xaaB\xb5r?ot%B.\xa0\xf4u% blablablah\x05\x05\x05\x05\x05'
>>>
Now I understand nothing. Maybe this is a bug of what? - Gunnar.Batz commented on September 26th 19 at 06:47