md5 数据加密测试

#!/usr/bin/env Python3
# -*- coding: utf-8 -*-
# @Software: PyCharm
# @virtualenv:workon
# @contact: 1040691703@qq.com
# @Desc:Code descripton
__author__ = '未昔/AngelFate'
__date__ = '2020/4/28 13:00'
import hashlib

test = "加密测试"

# 创建一个md5 对象
h1 = hashlib.md5()
# 此处必须声明encode
# 若写法为hl.update(str)  报错为: Unicode-objects must be encoded before hashing
h1.update(test.encode())
print("加密前", test)
print("加密后", h1.hexdigest())

加密前 加密测试
加密后 f447f32b28217406a6fb8772cdec471c

Process finished with exit code 0

md5 数据加密测试