【Python】使用hashlib进行MD5和sha1摘要计算

代码:

import hashlib

hash = hashlib.md5()
hash.update('http://www.cnblogs.com/xiandedanteng'.encode('utf-8'))
print(hash.hexdigest())

hash = hashlib.sha1()
hash.update('逆火'.encode('utf-8'))
print(hash.hexdigest())

输出:

C:Usershorn1Desktoppython47-md5>python md5.py
c42e84c421dc86b1117ce8d15a4f7712
4f31de3762c0f6b32494f3c9560ff1002de1047e

2018年5月13日

原文地址:https://www.cnblogs.com/heyang78/p/9033791.html