mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-11 07:19:30 -05:00
calculates sha1 checksum in chunks now. fixes #7
This commit is contained in:
parent
99c444dc4d
commit
b38809b5d2
@ -69,13 +69,15 @@ if __name__ == '__main__':
|
||||
sys.exit('{0} is not a file'.format(filename))
|
||||
|
||||
# calculate filehash, file size
|
||||
sha1 = hashlib.sha1()
|
||||
f = open(filename, 'rb')
|
||||
try:
|
||||
sha1.update(f.read())
|
||||
finally:
|
||||
f.close()
|
||||
filehash = sha1.hexdigest()
|
||||
print 'Calculate sha1 checksum'
|
||||
BLOCKSIZE = 65536
|
||||
hasher = hashlib.sha1()
|
||||
with open(filename, 'rb') as f:
|
||||
buf = f.read(BLOCKSIZE)
|
||||
while len(buf) > 0:
|
||||
hasher.update(buf)
|
||||
buf = f.read(BLOCKSIZE)
|
||||
filehash = hasher.hexdigest()
|
||||
filesize = os.path.getsize(filename)
|
||||
|
||||
# choose a port
|
||||
|
Loading…
Reference in New Issue
Block a user