本文介绍了传递列表到PyCrypto中的AES密钥生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Pycrypto生成AES密钥,但收到以下错误:

  aescipher = AES.new(mykey,AES.MODE_ECB)

c> mykey 是列表并包含 [1885434739,825373440,0,0] mykey 转换为

AES.new function?

解决方案

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:

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密钥生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 18:19