import hashlib
nmd5 = hashlib.md5('how to use mad5 in python hashlib'.encode(('utf-8')))
md5 = hashlib.md5('how to use md5 in python hashlib'.encode('utf-8'))
print(md5.hexdigest())
print(nmd5.hexdigest())
如果数据量很大,可以分块多次调用update(),最后计算结果是一样的
md52 = hashlib.md5()
md52.update('how to use md5 in '.encode('utf-8'))
md52.update('python hashlib'.encode('utf-8'))
print(md52.hexdigest())