CBC示例:
from aespython import cbc_mode, key_expander, aes_cipher
key = 'MluJMEZegVmrnWDaBiG1j7lqpkxNHh1v'
key = map(ord, key)
iv = 'cQUD1NUWNj0inTFp'
iv = map(ord, iv)
data = '9KWIuca1KKkB1Rna'
cipher = aes_cipher.AESCipher(key_expander.KeyExpander(256).expand(key))
cry = cbc_mode.CBCMode(cipher, 16)
cry.set_iv(iv)
encrypt_data = cry.encrypt_block(map(ord, data))找了一下并没有叫ECB模式的示例,自己摸索并测试成功,记录代码片段如下(之前部分与CBC模式一致):
#AES 128bit
cipher = aes_cipher.AESCipher(key_expander.KeyExpander(128).expand(key))
encrypt_data = cipher.cipher_block(map(ord, data))Java、C#双语版配套AES加解密示例
















