python-AES解密

from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
import base64

def aes_decrypt(ciphertext, key):
    """
    AES解密
    :param ciphertext:
    :param key:
    :return:
    """
    b_key = key.encode()
    cipher = AES.new(b_key, AES.MODE_CBC, IV)
    # 先base64编码一手
    base64Str = base64.b64decode(ciphertext)
    # 再解码一手
    dec_text = cipher.decrypt(base64Str).decode()
    # 去除补位
    dec_text = dec_text[:-ord(dec_text[-1])]
    return str(dec_text)

你可能感兴趣的:(python)