python hashlib 加密
日期: 2020-12-12 分类: 跨站数据 473次阅读
原文链接:https://book.apeland.cn/details/337/
用法:
import hashlib
# md5
m = hashlib.md5()
m.update(b"Hello")
m.update(b"It's me")
print(m.digest()) # 返回2进制格式的hash值
m.update(b"It's been a long time since last time we ...")
print(m.hexdigest()) # 返回16进制格式的hash值
# sha1
s1 = hashlib.sha1()
s1.update("小猿圈".encode("utf-8"))
print(s1.hexdigest())
# sha256
s256 = hashlib.sha256()
s256.update("小猿圈".encode("utf-8"))
print(s256.hexdigest())
# sha512
s512 = hashlib.sha512()
s512.update("小猿圈".encode("utf-8"))
print(s512.hexdigest())
除特别声明,本站所有文章均为原创,如需转载请以超级链接形式注明出处:SmartCat's Blog
标签:Python
精华推荐