- md5加密
>>> import hashlib >>> a=hashlib.md5() >>> a.update(b"Hello") >>> a.update(b"It‘s me") >>> print(a.digest()) #二进制显示 b‘]\xde\xb4{/\x92Z\xd0\xbf$\x9cR\xe3Br\x8a‘ >>> print(a.hexdigest()) #十进制显示 5ddeb47b2f925ad0bf249c52e342728a
2.sha1
>>> hash = hashlib.sha1() >>> hash.update(b‘admin‘) >>> print(hash.hexdigest()) d033e22ae348aeb5660fc2140aec35850c4da997
3.sha256
>>> hash = hashlib.sha256() >>> hash.update(b‘admin‘) >>> print(hash.hexdigest()) 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
4.sha384
>>> hash = hashlib.sha384() >>> hash.update(b‘admin‘) >>> print(hash.hexdigest()) 9ca694a90285c034432c9550421b7b9dbd5c0f4b6673f05f6dbce58052ba20e4248041956ee8c9a2ec9f10290cdc0782
5.sha512
>>> hash = hashlib.sha512() >>> hash.update(b‘admin‘) >>> print(hash.hexdigest()) c7ad44cbad762a5da0a452f9e854fdc1e0e7a52a38015f23f3eab1d80b931dd472634dfac71cd34ebc35d16ab7fb8a90c81f975113d6c7538dc69dd8de9077ec
6.hmac
>>> import hmac >>> h=hmac.new(b"admin") >>> h.update(b"hellwo") >>> print(h.hexdigest()) a3c0c2283a9d70ad02b50d9e1b3b2b67
时间: 2024-11-03 03:33:43