import hashlib
#
m=hashlib.md5()
m.update(b"hello")
print(m.hexdigest())#以16进制格式hash
print(m.digest()) #以2进制格式hash
m.update(b"It's me") #hello+it's me
print(m.hexdigest())
m.update(b"go to the school")
print(m.hexdigest())

m2=hashlib.md5()
m2.update("helloIt's me天王盖地虎".encode(encoding="UTF-8")) #encode成字节模式(bytes)
print(m2.hexdigest())

s2=hashlib.sha1()
s2.update(b"helloIt's me")
print(s2.hexdigest())

import hmac

h=hmac.new(b"12345","you are 250天王".encode(encoding="UTF-8"))
print(h.digest()) #不支持中文(需要encode)
print(h.hexdigest()) #不支持中文