mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-25 14:07:37 -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))
|
sys.exit('{0} is not a file'.format(filename))
|
||||||
|
|
||||||
# calculate filehash, file size
|
# calculate filehash, file size
|
||||||
sha1 = hashlib.sha1()
|
print 'Calculate sha1 checksum'
|
||||||
f = open(filename, 'rb')
|
BLOCKSIZE = 65536
|
||||||
try:
|
hasher = hashlib.sha1()
|
||||||
sha1.update(f.read())
|
with open(filename, 'rb') as f:
|
||||||
finally:
|
buf = f.read(BLOCKSIZE)
|
||||||
f.close()
|
while len(buf) > 0:
|
||||||
filehash = sha1.hexdigest()
|
hasher.update(buf)
|
||||||
|
buf = f.read(BLOCKSIZE)
|
||||||
|
filehash = hasher.hexdigest()
|
||||||
filesize = os.path.getsize(filename)
|
filesize = os.path.getsize(filename)
|
||||||
|
|
||||||
# choose a port
|
# choose a port
|
||||||
|
Loading…
x
Reference in New Issue
Block a user