You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
702 B
28 lines
702 B
from Crypto.Cipher import AES
|
|
from Crypto.Util.Padding import pad
|
|
|
|
"""
|
|
8.13 xhs-aes版本
|
|
"""
|
|
def encrypt_aes_cbc(plaintext):
|
|
"""
|
|
aes-cbc
|
|
:param plaintext:
|
|
:return:
|
|
"""
|
|
key = "3061396677336d3671666c6c3264656a"
|
|
iv = "6d686171686e6a6d723072736f6f336f"
|
|
cipher = AES.new(bytes.fromhex(key), AES.MODE_CBC, bytes.fromhex(iv))
|
|
ciphertext = cipher.encrypt(pad(bytes.fromhex(plaintext), AES.block_size))
|
|
return ciphertext.hex()
|
|
|
|
|
|
def aes_encrypt(plain_text):
|
|
"""
|
|
转换一下为 hex字符串便于加密操作
|
|
:param plain_text:
|
|
:return:
|
|
"""
|
|
array = "".join([hex(i)[2:] for i in plain_text])
|
|
payload = encrypt_aes_cbc(array)
|
|
return payload
|