aes - Crypto.Cipher.AES.new 中的默认模式

标签 aes pycrypto

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/

相关文章:

python - PyCrypto 导出/导入签名

macos - PyCrypto 在 CFB 模式下与 CommonCrypto 的兼容性?

java - Android到服务器的AES加密/解密

c# - 为什么我的解密文本中出现随机字符?

java - 错误: Given final block not properly padded

PHP 和 MySQL 安全 : one-way encryption Vs two-way encryption

java - 需要有关 AES CTR 密码 python 与 Java 的建议

python - 如何在 pycryptodome 中使用 ECC 加密消息

Python - Pycrypto - 通过网络发送加密数据

php - 将 PHP 中的 openssl AES 转换为 Python AES