资源简介
AES加解密(AESEncryptScript.py)
代码片段和文件信息
#!/usr/bin/python3
#-*- coding:UTF-8 -*-
from Crypto.Cipher import AES
import sys getopt
class SkyAES(object):
#bits:128192256
#key必须是16的整数倍,而且其长度=bits/8
#iv是初始向量
BLOCK_LENGTH=16
def __init__(self key bits iv mode):
self.key = key
self.bits = bits
self.iv = iv
self.mode = mode
self.cryptor = AES.new(self.key self.mode)
def encrypt(self data):
#padding 0x00
c = len(data)
if (c%self.BLOCK_LENGTH != 0):
pad_c = self.BLOCK_LENGTH - (c%self.BLOCK_LENGTH)
else:
pad_c = 0
data = data + (‘\000‘*pad_c)
return self.cryptor.encrypt(data)
def decrypt(self data):
c = len(data)
if (c%self.BLOCK_LENGTH != 0):
pad_c = self.BLOCK_LENGTH - (c%self.BLOCK_LENGTH)
else:
pad_c = 0
data = data + (‘\000‘*pad_c)
return self.cryptor.decrypt(data).rstrip(‘\000‘)
class SkyAES_ECB(SkyAES):
def __init__(self key bits):
super(SkyAES_ECB self).__init__(key bits None AES.MODE_ECB)
class SkyEncryptscript(SkyAES_ECB):
#fixed value please do not modify.
#
script_KEY_STRINGS=“NcPlUS@@sKy#!%$^“
script_TAG=“NC+S“
def __init__(self):
key = self.script_KEY_STRINGS
super(SkyEncryptscript self).__init__(key 128)
def encrypt_file(self in_name out_name):
in_f = open(in_name “r“)
data = in_f.read()
in_f.close()
en_data = self.encrypt(data)
ou
相关资源
- python实现图像的混沌加密解密
- 纯python实现的RC4加解密
- 纯python实现的AES加解密
- 用PYTHON实现的各类经典加解密算法
- Python实现国密SM2密钥分配加解密、数
- python实现AES密钥扩展
- 生意参谋transit-id和data解密源码
- luajit 2.1.0 bate解密工具
- python3.8爬取拉勾教育mp4视频解密m3u8到
- pycrypto-2.6.1
-
ba
se家族加密解密.py - 微信电脑版image文件夹dat图片解码解密
- python 简单的加密解密软件
- python加密解密技术
- 密码学 AES算法 Python代码实现
- python实现简单的加密通信
评论
共有 条评论