Trouble with encode + encrypt + pad using same code for python2 and python3

前端 未结 4 2068
渐次进展
渐次进展 2021-01-19 04:07

Disclaimer: I understand that the following is not suited to give "security" in a production environment. It is simply meant as "a little bit

4条回答
  •  清酒与你
    2021-01-19 04:35

    One problem with your code is that you are using the same cipher object for both encryption and decryption. This won't work, as the cipher objects are stateful:PyCrypto Documentation

    You can create another object for decrypting, as in: crypto2 = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456'), and then use this object to decrypt.

提交回复
热议问题