python---使用MD5加密

import hashlib


# 要加密的信息
info = 'this is a test information'

# 创建MD5对象
m = hashlib.md5()

# 将待加密的信息转换为bytes
b_info = info.encode('utf-8')

# 对信息进程假面
m.update(b_info)

# 获取密文
info_md5 = m.hexdigest()


print('加密之前', info)
print('加密之后', info_md5)


# 加密之前 this is a test information
# 加密之后 fa35c19039642b5b072f863426ce1a4e

posted @ 2020-03-29 16:19  凯旋.Lau  阅读(229)  评论(0编辑  收藏  举报