AES decryption fails when decrypting a second time
问题 I have this implementation of a reversible encoding: # coding=utf-8 from Crypto.Cipher import AES from Crypto import Random import uuid import unittest import random key = r'Sixteen byte key' # Keep this real secret iv = Random.new().read(AES.block_size) cipher = AES.new(key, AES.MODE_CFB, iv) def encode(role, plaintext): '''Encode the message, prefix with the role specifier''' msg = iv + cipher.encrypt(plaintext) msg = msg.encode('hex') msg = role + '-' + msg return msg def decode(msg): ''