AES解密测试 – vulsee.com 微慑网
1、模块安装
python下安装pycryptodome:
Python39使用:
pip install pycryptodomex
其他使用:
pip3 install pycryptodome
2、示例:
from Cryptodome.Cipher import AES
from Cryptodome.Util.Padding import unpad
import binascii
key = b'8VBkO5amPcPrXV3m'
iv = b'2233445566778899'
ciphertext = 'F9B2DB94D81FD68862BA21AE1F36888C17142E5F7F5B015FFA4828C5655ED02E60D622BFD47F056927FA6B6AE6322C5E5AF458E6C52D75DB27811D4419661CA90482DE758045F4130323DCE92CA3C6C5C51A55D46A48EE162DC2A39171B0FAE849BCBDBB75B6D185ED76423718643421' # 输入的16进制密文
ciphertext_bytes = binascii.unhexlify(ciphertext) # 将输入的16进制字符串转换为bytes格式
#以下默认使用pksc7,如果需要使用其他填充padding,参考:
#cipher = AES.new(key, mode, iv, padding=iso_padding) # 创建AES CBC密码实例
cipher = AES.new(key, AES.MODE_CBC, iv) # 创建AES CBC密码实例
plaintext = unpad(cipher.decrypt(ciphertext_bytes), AES.block_size) # 解密并删除填充
print(plaintext)