AES: how to detect that a bad password has been entered?
问题 A text s has been encrypted with: s2 = iv + Crypto.Cipher.AES.new(Crypto.Hash.SHA256.new(pwd).digest(), Crypto.Cipher.AES.MODE_CFB, iv).encrypt(s.encode()) Then, later, a user inputs the password pwd2 and we decrypt it with: iv, cipher = s2[:Crypto.Cipher.AES.block_size], s2[Crypto.Cipher.AES.block_size:] s3 = Crypto.Cipher.AES.new(Crypto.Hash.SHA256.new(pwd2).digest(), Crypto.Cipher.AES.MODE_CFB, iv).decrypt(cipher) Problem: the last line works even if the entered password pw2 is wrong . Of