Skip to content

Instantly share code, notes, and snippets.

@blubberdiblub
Last active July 20, 2017 04:36
Show Gist options
  • Save blubberdiblub/5a8bc84403cfed0ec063 to your computer and use it in GitHub Desktop.
Save blubberdiblub/5a8bc84403cfed0ec063 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import hashlib
def chunked_sha1sum(filelike, chunk_size=0x100000):
hasher = hashlib.new('sha1')
while True:
chunk = filelike.read(chunk_size)
if not chunk:
break
hasher.update(chunk)
return hasher.hexdigest()
with open('some_dvd_dump.iso', 'rb') as f:
sha1sum = chunked_sha1sum(f)
print(sha1sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment