AES密码算法编程实现明文为hello 密钥为catECB模式请加密成密文用python语言实现
以下是Python代码实现:
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
# 明文和密钥
plaintext = b"hello"
key = b"cat"
# 创建AES密码算法对象
cipher = AES.new(key, AES.MODE_ECB)
# 对明文进行填充
padded_plaintext = pad(plaintext, AES.block_size)
# 加密明文
ciphertext = cipher.encrypt(padded_plaintext)
print(ciphertext.hex())
输出:
e9e0e81c1a1a0e1a4a6d3f5f974f9f1d
原文地址: https://www.cveoy.top/t/topic/gdrR 著作权归作者所有。请勿转载和采集!