首先,老规矩,下代码前先了解md5的几个函数
python中digest()和hexdigest()区别:
其中
hash.digest()
返回摘要,作为二进制数据字符串值
hash.hexdigest()
返回摘要,作为十六进制数据字符串值
import hashlib
def get_md5(password):
#1- 实例化加密对象
md5 = hashlib.md5()
#2- 进行加密操作
md5.update(password.encode('utf-8'))
#3- 返回加密后的结果
return md5.hexdigest()