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))

 

相关文章:

  • 2021-08-31
  • 2022-12-23
  • 2021-12-06
  • 2023-03-17
  • 2021-12-27
  • 2021-09-14
猜你喜欢
  • 2021-12-16
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2021-05-20
  • 2021-07-07
  • 2021-08-29
相关资源
相似解决方案