在Crypto.Cipher.AES.new(key, mode, *args, **kwargs)
方法中,只提供一个参数时默认的模式是什么:
cipher = AES.new(key)
Crypted = cipher.encrypt(plaintext)
文档只是说:
mode (One of the supported MODE_* constants) – The chaining mode to use for encryption or decryption. If in doubt, use MODE_EAX.
最佳答案
欧洲央行。 docs 中有详细说明。 。 (我不确定您正在查看哪些。自您拥有的版本以来,文档可能已经得到了改进。)
new(key, *args, **kwargs)
Create a new AES cipher
Parameters:
key (byte string) - The secret key to use in the symmetric cipher. It must be 16 (AES-128), 24 (AES-192), or 32 (AES-256) bytes long.
mode (a MODE_* constant) - The chaining mode to use for encryption or decryption. Default is MODE_ECB.
...
通常,我不会在这里依赖默认值。它对加密有重大影响,对于任何阅读代码的人来说都很重要。 (此外,ECB 几乎总是错误的使用模式。它只有在非常受控的情况下才是安全的。)
关于aes - Crypto.Cipher.AES.new 中的默认模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66295205/