import hashlib # 主要提供SHA1, SHA224, SHA256, SHA384, SHA512, MD5 tmp = hashlib.md5() tmp.update(b'hello') print(tmp.hexdigest()) tmp.update('ddd的ddd'.encode(encoding='utf-8')) print(tmp.hexdigest()) import hmac # 双层加密,速度比较快,用于消息加密 htmp = hmac.new(b"meirong", b"hinimix") print(htmp.digest()) print(htmp.hexdigest())