Skip to content

Instantly share code, notes, and snippets.

@mayneyao
Forked from aunyks/large-file-hash.py
Created April 13, 2018 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayneyao/48248957f6bfc99c3dd9a3beb82e26bf to your computer and use it in GitHub Desktop.
Save mayneyao/48248957f6bfc99c3dd9a3beb82e26bf 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