14 lines
387 B
Python
14 lines
387 B
Python
"""
|
||
对密码进行md5加密
|
||
"""
|
||
import hashlib
|
||
from django.conf import settings # 要用到settings.py文件中的SECRET_KEY字符串,对产生的md5加密字符串加盐
|
||
|
||
def md5(data_string):
|
||
|
||
salt = settings.SECRET_KEY
|
||
# 对产生的md5加密字符串加盐
|
||
obj = hashlib.md5(salt.encode('utf-8'))
|
||
obj.update(data_string.encode('utf-8'))
|
||
return obj.hexdigest()
|