1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#encoding:utf-8
"""
示例代码
"""
fromCrypto.CipherimportAES
key='0123456789abcdef'
mode=AES.MODE_CBC
encryptor=AES.new(key, mode)
text='j'*64+'i'*128
ciphertext=encryptor.encrypt(text)
"""
上例中的key是16位, 还能够是24 或 32 位长度, 其对应为 AES-128, AES-196 和 AES-256.
解密则能够用如下代码进行:
"""
#decryptor = AES.new(key, mode)
#plain = decryptor.decrypt(ciphertext)
|