Last active
December 7, 2024 16:34
-
-
Save aunyks/042c2798383f016939c40aa1be4f4aaf to your computer and use it in GitHub Desktop.
Hash a large file in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Just for the sake of making a function.