传递列表到PyCrypto中的AES密钥生成器 [英] Pass list to AES key generator in PyCrypto
问题描述
我尝试使用Pycrypto生成AES密钥,但收到以下错误:
TypeError:'list'对于以下语句的缓冲区接口
:
aescipher = AES.new(mykey,AES.MODE_ECB)
c> mykey 是列表
并包含 [1885434739,825373440,0,0] $ c $有没有人知道如何将
mykey
转换为
AES密钥。原始键字节通常使用 keysize / 8
字节的字节数组提供。对于AES,支持的唯一键大小分别为128,192和256位或16,24和32字节。
请注意,填充键直到适合可能导致到主要的加密漏洞。所以是使用ECB模式,而不是像CBC(或一个也提供认证/完整性保护,如GCM当然)更安全的模式。
I'm attempting to generate an AES key with Pycrypto but receive the following error:
TypeError: 'list' does not support the buffer interface
for the following statement:
aescipher = AES.new(mykey, AES.MODE_ECB)
mykey
, is of type list
and contains [1885434739, 825373440, 0, 0]
Does anyone know how I can convert mykey
into the correct type for the AES.new
function?
You should not supply any kind of list/array when creating an AES key. The raw key bytes are normally supplied using a byte array of keysize / 8
bytes. For AES, the only key sizes that are supported are 128, 192 and 256 bits or 16, 24 and 32 bytes respectively.
Note that padding keys until they fit may lead to major cryptographic vulnerabilities. So is using ECB mode instead of a more secure mode like CBC (or one that also provides authentication/integrity protection such as GCM of course).
这篇关于传递列表到PyCrypto中的AES密钥生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!