Python 3 AESエラーValueError:Incorrect AES key length(95 bytes)

3505 ワード

Traceback (most recent call last):
File “C:\Users\billl\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\interactiveshell.py”, line 2963in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File “”, line 1in 
AES.new(“asssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdfasasasasa”, AES.MODE_ECB)
File “C:\Users\billl\AppData\Local\Continuum\anaconda3\lib\site-packages\Crypto\Cipher\AES.py”, line 232in new
return create_cipher(sys.modules[name], keymode, *args, **kwargs)
File "C:\Users\billl\AppData\Local\Continuum\anaconda3\lib\site-packages\Crypto\Cipher_init.py", line 79in _create_cipher
return modes[mode](factory, **kwargs)
File “C:\Users\billl\AppData\Local\Continuum\anaconda3\lib\site-packages\Crypto\Cipher_mode_ecb.py”, line 215in _create_ecb_cipher
cipher_state = factory._create_base_cipher(kwargs)
File “C:\Users\billl\AppData\Local\Continuum\anaconda3\lib\site-packages\Crypto\Cipher\AES.py”, line 93in _create_base_cipher
raise ValueError(“Incorrect AES key length (%d bytes)” % len(key))
ValueError: Incorrect AES key length (95 bytes)

このエラーはAESのKEY長さが制限を超えているということです
MODE以外SIVモードkey長さ:32,48,or 64、残りのkey長さ16,24 or 32の内部関数説明:
“”"Create a new AES cipher.
:param key:
    The secret key to use in the symmetric cipher.

    It must be 16, 24 or 32 bytes long (respectively for *AES-128*,
    *AES-192* or *AES-256*).

    For ``MODE_SIV`` only, it doubles to 32, 48, or 64 bytes.
:type key: bytes/bytearray/memoryview

:param mode:
    The chaining mode to use for encryption or decryption.
    If in doubt, use ``MODE_EAX``.
:type mode: One of the supported ``MODE_*`` constants

ID:Pythonの戦い
|作|者|公(zhong)号:pythonの戦い
Pythonに集中し、ネット爬虫類、RPAに専念する学習-実践-総括
テクノロジーのボトルネックの研究と共有が好きで、注目を歓迎します.
独学で友がいなければ、孤陋で寡聞だ.