AES算法简单调用

AES算法简单调用

加密

from Crypto.Cipher import AES
pattern = AES.new('This is a key123', AES.MODE_CBC, 'This is an test1')
message = "szj".zfill(16)
ciphertext = pattern.encrypt(message)
print(message)
print(ciphertext)

在这里插入图片描述

解密

from Crypto.Cipher import AES
pattern = AES.new('This is a key123', AES.MODE_CBC, 'This is an test1')
message = pattern.decrypt("_t\x7f\x97X\x12`\xe1\xb5\x13\x81\xc2\xa4\x9by\xa9")
print(message.strip('0'))

在这里插入图片描述

发布了42 篇原创文章 · 获赞 7 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/szj_jojoli/article/details/98627103