求助!关于encrypt问题!

运行报错:raiseValueError(“IncorrectAESkeylength(%dbytes)”%len(key))ValueError:IncorrectAESkeylength(51bytes)

token=encrypt(uuid.uuid4().hex.upper(),'xd7xdfxca2xd0Vhuxebx06xa0xbanxa2x07Oxc1x8bxcfx8f2txc0x92xc4xa5x0bxb4xe7xbc')defencrypt(x,key,pad=False):ifpad:pad=16-(len(x)%16)x=x+chr(pad)*padiv=os.urandom(16)y=AES.new(key.encode("utf8"),AES.MODE_CBC,iv)#这一行报错,32位的key为什么转码就变成了51?难道不是utf8字符?returnbase64.b64encode(iv+y.encrypt(x))

发表评论