Commit 45ef7bbe by fanxun

md5加盐加密改造

parent 55839aaa
import hashlib import hashlib
from Crypto.Cipher import AES # from Crypto.Cipher import AES
from Crypto.Util.Padding import pad # from Crypto.Util.Padding import pad
from base64 import encodebytes from base64 import encodebytes
# 加密类 # 加密类
class Encryption: class Encryption:
def get_md5(self,pwd): def get_md5(self, pwd, salt=None):
"""md5加密成32位小写""" """md5加密成32位小写"""
md5 = hashlib.md5() md5 = hashlib.md5()
if salt:
pwd = pwd + salt
else:
pwd = pwd
if pwd: if pwd:
md5.update(pwd.encode('utf-8')) md5.update(pwd.encode('utf-8'))
print(md5.hexdigest().lower())
return md5.hexdigest().lower() return md5.hexdigest().lower()
else: else:
return '' return ''
...@@ -25,3 +30,7 @@ class Encryption: ...@@ -25,3 +30,7 @@ class Encryption:
encrypted_text_str = encrypted_text.replace("\n", "") encrypted_text_str = encrypted_text.replace("\n", "")
# 此处我的输出结果老有换行符,所以用了临时方法将它剔除 # 此处我的输出结果老有换行符,所以用了临时方法将它剔除
return encrypted_text_str return encrypted_text_str
if __name__ == '__main__':
Encryption().get_md5('fx123456', 'hikcreate_xj')
\ No newline at end of file
...@@ -2,6 +2,13 @@ class BaseConfig(): ...@@ -2,6 +2,13 @@ class BaseConfig():
"""基础配置类""" """基础配置类"""
# 请求头 # 请求头
headers = {'Content-Type': 'application/json; charset=utf-8'} headers = {'Content-Type': 'application/json; charset=utf-8'}
# 钉钉群webhook
class DingTalk(BaseConfig):
"""钉钉机器人"""
webhook = '' webhook = ''
class SSOLoginConfig(BaseConfig):
"""登录配置"""
salt = 'hikcreate_xj'
\ No newline at end of file
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