Skip to content

Instantly share code, notes, and snippets.

@Gunni
Created July 19, 2019 18:43
Show Gist options
  • Save Gunni/7c1c00b2390c1472492ac12042f06c06 to your computer and use it in GitHub Desktop.
Save Gunni/7c1c00b2390c1472492ac12042f06c06 to your computer and use it in GitHub Desktop.
python sha512 using mmap
# Switch sha512 out for any other if you want
# Use hexdigest if you want a "normal" hex version of the digest
def hashFile(path):
with open(path, 'r') as fh, mmap.mmap(fh.fileno(), 0, prot=mmap.PROT_READ) as map:
return hashlib.sha512(map).digest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment