# -*- coding: utf-8 -*-
# @Time : 2020/2/17 13:16
# @Author : Jackey-lu
# @File : hashlib模块.py
import hashlib
m = hashlib.md5()
print(m)
m.update('hello world!'.encode('utf8'))
print(m.hexdigest())
m.update('lzh'.encode('utf8'))
print(m.hexdigest())
s = hashlib.sha256()
s.update('hello world!'.encode('utf8'))
print(s.hexdigest())
输出
<md5 HASH object @ 0x000002EE68F785D0>
fc3ff98e8c6a0d3087d515c0473f8677
68dd51a414b2bb523095ad5aa46bcff5
7509e5bda0c762d2bac7f90d758b5b2263fa01ccbc542ab5e3df163be08e6ca9