【发布时间】:2016-06-30 12:48:45
【问题描述】:
我有一些python代码,
hash_object = hashlib.sha256(b'Hello World')
hex_dig = hash_object.hexdigest()
cipher = AES.new(hex_dig, AES.MODE_CBC, iv)
plain = cipher.decrypt( cipher )
但是,我有一个错误 - ValueError: AES key must be either 16, 24, or 32 bytes long
但是,我想要 32 字节的密钥,而不是 16 字节的密钥。 我不知道为什么 hash_val=hashfct.digest() 不是 32bytes 另外,我尝试了“hash_val=hashfct.digest()[0:32]”,但它也不起作用。
如何获取 32 字节长的密钥?
谢谢。
【问题讨论】: