Python AES 加密实现 - 使用 pycryptodome 库加密 'hello'
from Crypto.Cipher import AES
将明文和密钥都转换为字节串
plaintext = b'hello' key = b'cat'
创建AES加密器对象
cipher = AES.new(key, AES.MODE_ECB)
对明文进行填充
plaintext_padded = plaintext + (AES.block_size - len(plaintext) % AES.block_size) * b'\x00'
加密明文
ciphertext = cipher.encrypt(plaintext_padded)
打印密文
print(ciphertext.hex())
原文地址: https://www.cveoy.top/t/topic/fWH7 著作权归作者所有。请勿转载和采集!