IV must be 16 bytes long error in AES encryption
问题 I am using pycrypto module for AES encryption. And using documentation I have write down the below function but it al;ways gives error IV must be 16 bytes long but I am using 16 byte long IV. def aes_encrypt(plaintext): """ """ key = **my key comes here** iv = binascii.hexlify(os.urandom(16)) # even used without binascii.hexlify) aes_mode = AES.MODE_CBC obj = AES.new(key, aes_mode, iv) ciphertext = obj.encrypt(plaintext) return ciphertext 回答1: Use this: from Crypto.Cipher import AES import