MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / aesEncrypt

Function aesEncrypt

backup/sysxc.py:92–107  ·  view source on GitHub ↗

AES的ECB模式加密方法 :param key: 密钥 :param data:被加密字符串(明文) :return:密文

(key, data)

Source from the content-addressed store, hash-verified

90
91
92def aesEncrypt(key, data):
93 '''
94 AES的ECB模式加密方法
95 :param key: 密钥
96 :param data:被加密字符串(明文)
97 :return:密文
98 '''
99 key = key.encode('utf8')
100 # 字符串补位
101 data = pad(data)
102 cipher = AES.new(key, AES.MODE_ECB)
103 # 加密后得到的是bytes类型的数据,使用Base64进行编码,返回byte字符串
104 result = cipher.encrypt(data.encode())
105 encodestrs = base64.b64encode(result)
106 enctext = encodestrs.decode('utf8')
107 return enctext
108
109
110def aesDecrypt(key, data):

Callers 1

mainFunction · 0.70

Calls 2

encryptMethod · 0.80
padFunction · 0.70

Tested by

no test coverage detected