在社区搜了下,发现竟找不到一个解密一物一码的示例!
花时间研究了下,终于测试成功了,我来分享个python版本。
python 3.8
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.backends import default_backend
from base64 import b64decode, b64encode
backend = default_backend()
padder = padding.PKCS7(128).padder()
unpadder = padding.PKCS7(128).unpadder()
# 修改这里 密钥从申请一物一码的站内信获取
key = b'xxxxxxxxxxxxxxxx'
iv = b'xxxxxxxxxxxxxxxx'
# 下载的base64编码文件
b64Data = b64decode(
open("1w.base64", "r").read()
)
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend)
decryptor = cipher.decryptor()
plain = decryptor.update(b64Data) + decryptor.finalize()
plain = unpadder.update(plain) + unpadder.finalize()
f = open("ok.txt", "wb")
f.write(plain)
f.close()
亲测可用, 补充:需要安装 cryptography ;
pip install cryptography
赞!