相关疑难解决方法(0)

在Python中散列文件

我想让python读取到EOF,这样我就可以得到一个合适的哈希值,无论是sha1还是md5.请帮忙.这是我到目前为止:

import hashlib

inputFile = raw_input("Enter the name of the file:")
openedFile = open(inputFile)
readFile = openedFile.read()

md5Hash = hashlib.md5(readFile)
md5Hashed = md5Hash.hexdigest()

sha1Hash = hashlib.sha1(readFile)
sha1Hashed = sha1Hash.hexdigest()

print "File Name: %s" % inputFile
print "MD5: %r" % md5Hashed
print "SHA1: %r" % sha1Hashed
Run Code Online (Sandbox Code Playgroud)

python hash md5 sha1 hashlib

67
推荐指数
6
解决办法
7万
查看次数

标签 统计

hash ×1

hashlib ×1

md5 ×1

python ×1

sha1 ×1