美文网首页
python验证md5/sha1/sha256

python验证md5/sha1/sha256

作者: Cindy小隐 | 来源:发表于2017-04-12 16:35 被阅读0次
import sys
import hashlib

# BUF_SIZE is totally arbitrary, change for your app!
BUF_SIZE = 65536  # lets read stuff in 64kb chunks!

md5 = hashlib.md5()
sha1 = hashlib.sha1()
sha256 = hashlib.sha256()

with open(sys.argv[1], 'rb') as f:
    while True:
        data = f.read(BUF_SIZE)
        if not data:
            break
        md5.update(data)
        sha1.update(data)

print("MD5: {0}".format(md5.hexdigest()))
print("SHA1: {0}".format(sha1.hexdigest()))
print("SHA256: {0}".format(sha256.hexdigest()))

相关文章

网友评论

      本文标题:python验证md5/sha1/sha256

      本文链接:https://www.haomeiwen.com/subject/ekbmattx.html