python aes解密脚本

本文介绍如何在Windows环境下使用Python2.7进行AES CBC模式的解密操作,包括设置编码格式、导入必要的库以及实现解密函数的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境:windows python2.7

代码: 

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import base64
from Crypto.Cipher import AES


# 密钥(key), 密斯偏移量(iv) CBC模式加密


def AES_Decrypt(key, data):
    vi = '1234567890123456'
    data = data.encode('utf8')
    encodebytes = base64.b64decode(data)
    # 将加密数据转换位bytes类型数据
    cipher = AES.new(key.encode('ASCII'), AES.MODE_CBC, vi.encode('utf8'))
    text_decrypted = cipher.decrypt(encodebytes)


    # 去补位
    text_decrypted = text_decrypted.decode('utf8')
    return text_decrypted


key = 'EaRncVfLgIPMaygA'
data = 'kt1zBVG4Om1rVxe2ISqt1WFZ+tWvgNV3QygfrSlFRjI='
text_decrypted = AES_Decrypt(key, data)
print(text_decrypted)


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值