Commit e445fbdf by fanxun

保存

parents 268e348e d4fe53ad
...@@ -17,8 +17,6 @@ class RedisString(RedisBase): ...@@ -17,8 +17,6 @@ class RedisString(RedisBase):
return result return result
if __name__ == '__main__': if __name__ == '__main__':
# r= RedisString(6).get('bmc:captcha:bf46c0c0-11b4-4b7d-99d7-530f77f8ab88') # r= RedisString(6).get('bmc:captcha:bf46c0c0-11b4-4b7d-99d7-530f77f8ab88')
# r = RedisString(0).get('edl:sms_value:17822000010:MOBILE_REGISTER') # r = RedisString(0).get('edl:sms_value:17822000010:MOBILE_REGISTER')
......
import requests import requests,hashlib
import json import json
from config import BaseConfig from config import BaseConfig
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
from base64 import encodebytes
def dingTalk(webhook, message): def dingTalk(webhook, message):
"""发送消息到钉钉群""" """发送消息到钉钉群"""
...@@ -9,3 +12,26 @@ def dingTalk(webhook, message): ...@@ -9,3 +12,26 @@ def dingTalk(webhook, message):
post_data = json.dumps(data) post_data = json.dumps(data)
response = requests.post(webhook, headers=BaseConfig.headers, data=post_data) response = requests.post(webhook, headers=BaseConfig.headers, data=post_data)
return response.text return response.text
# 加密类
class Encryption:
def get_md5(self,pwd):
"""md5加密成32位小写"""
md5 = hashlib.md5()
if pwd:
md5.update(pwd.encode('utf-8'))
return md5.hexdigest().lower()
else:
return ''
def aes_cipher(self,key, aes_str):
"""AES采用ECB模式,使用PKCS7补偿"""
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(encodebytes(encrypt_aes), encoding='utf-8') # 解码
encrypted_text_str = encrypted_text.replace("\n", "")
# 此处我的输出结果老有换行符,所以用了临时方法将它剔除
return encrypted_text_str
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment