Skip to content

Instantly share code, notes, and snippets.

@sayef
Forked from aunyks/large-file-hash.py
Created June 29, 2022 20:01
Show Gist options
  • Select an option

  • Save sayef/d2de755abadafc0a07acfad51f30b62a to your computer and use it in GitHub Desktop.

Select an option

Save sayef/d2de755abadafc0a07acfad51f30b62a to your computer and use it in GitHub Desktop.
Hash a large file in Python
import hashlib as hash
# Specify how many bytes of the file you want to open at a time
BLOCKSIZE = 65536
sha = hash.sha256()
with open('kali.iso', 'rb') as kali_file:
file_buffer = kali_file.read(BLOCKSIZE)
while len(file_buffer) > 0:
sha.update(file_buffer)
file_buffer = kali_file.read(BLOCKSIZE)
print sha.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment