高级加密标准(英语:Advanced Encryption Standard,缩写:AES),用来替代DES
from Crypto.Cipher import AES
from Crypto import Random
data = '王王王王' # 要加密的明文
key = b'this is a 16 key' # 密钥key必须为 16(AES-128), 24(AES-192), 32(AES-256)
iv = Random.new().read(AES.block_size) # 不可重复的密钥向量
mycipher = AES.new(key, AES.MODE_CFB, iv)
ciptext = iv + mycipher.encrypt(data.encode())
mydecrypt = AES.new(key, AES.MODE_CFB, ciptext[:16])
decrytext = mydecrypt.decrypt(ciptext[16:])
decrytext.decode()
参考:
https://blog.csdn.net/ruanxingzi123/article/details/83017575