from M2Crypto.EVP import Cipher from M2Crypto import m2 from M2Crypto import util ENCRYPT_OP = 1 # 加密操作 DECRYPT_OP = 0 # 解密操作 iv = '\0' * 16 # 初始化变量,对于aes_128_ecb算法无用 PRIVATE_KEY = 'dd7fd4a156d28bade96f816db1d18609' # 密钥 def Encrypt(data): '使用aes_128_ecb算法对数据加密' cipher = Cipher(alg = 'aes_128_ecb', key = PRIVATE_KEY, iv = iv, op = ENCRYPT_OP) buf = cipher.update(data) buf = buf + cipher.final() del cipher # 将明文从字节流转为16进制 output = '' for i in buf: output += 'X' % (ord(i)) return output def Decrypt(data): '使用aes_128_ecb算法对数据解密' # 将密文从16进制转为字节流 data = util.h2b(data) cipher = Cipher(alg = 'aes_128_ecb', key = PRIVATE_KEY, iv = iv, op = DECRYPT_OP) buf = cipher.update(data) buf = buf + cipher.final() del cipher return buf
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有