def aes_encrypt(key, data):
    # 使用key,选择加密方式
    aes = AES.new(key.encode('utf-8'), AES.MODE_ECB)
    pad_pkcs7 = pad(aes_str.encode('utf-8'), AES.block_size,
                    style='pkcs7')  # 选择pkcs7补全
    encrypt_aes = aes.encrypt(pad_pkcs7)
    # 加密结果
    encrypted_text = str(base64.encodebytes(
        encrypt_aes), encoding='utf-8')  # 解码
    encrypted_text_str = encrypted_text.replace("\n", "")

    return encrypted_text_str


if __name__ == '__main__':
    data = 'adfdsf'
    key = 'bWFsbHB3ZA==WNST'
    print(aes_encrypt(key, data))