python 实现哈希sha1加密
Python 2023/4/11 23:29:26 点击:不统计
原载于:原文章%77w%77%2Ef%6F%72%61%73%70%2E%63n
python 实现sha1加密
需要hashlib 库,python 自带对应库,不需要安装
直接看代码:
import hashlib
def sha1_encode(str_code):
return hashlib.sha1(str_code.encode("utf-8")).hexdigest()
if __name__ == "__main__":
code = '123456'
# 哈希sha1加密
str_sha1 = sha1_encode(code)
print(code, "哈希加密sha1加密后", str_sha1) # 结果:7c4a8d09ca3762af61e59520943dc26494f8941b
print("加密后长度", len("7c4a8d09ca3762af61e59520943dc26494f8941b")) # 输出长度 40
<网f站o学a习s制p作.cn>
·上一篇:python MD5加密 >> ·下一篇:python 判断 包含数字 >>