我想知道我是否可以对这个python脚本有一些新的眼光.它适用于中小型文件,但是大型文件(4-8GB左右)在运行几分钟后会出现无法解决的崩溃.
要么:
import sys
import msvcrt
import hashlib
#Print the file name (and its location) to be hashed
print 'File: ' + str(sys.argv[1])
#Set "SHA1Hash" equal to SHA-1 hash
SHA1Hash = hashlib.sha1()
#Open file specified by "sys.argv[1]" in read only (r) and binary (b) mode
File = open(sys.argv[1], 'rb')
#Get the SHA-1 hash for the contents of the specified file
SHA1Hash.update(File.read())
#Close the file
File.close()
#Set "SHA1HashBase16" equal to the hexadecimal of "SHA1Hash"
SHA1HashBase16 = SHA1Hash.hexdigest()
#Print the SHA-1 …Run Code Online (Sandbox Code Playgroud)