-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
22 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ pydantic = "*" | |
requests = "*" | ||
python-slugify = "*" | ||
dateparser = "*" | ||
checksum = "*" | ||
|
||
[dev-packages] | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
# Python program to find MD5 hash value of a file | ||
import hashlib | ||
import sys | ||
|
||
def checksum_file(filename:str) -> str: | ||
md5_hash = hashlib.md5() | ||
with open(filename,"rb") as f: | ||
# Read and update hash in chunks of 4K | ||
for byte_block in iter(lambda: f.read(4096),b""): | ||
md5_hash.update(byte_block) | ||
return md5_hash.hexdigest() | ||
|
||
|
||
def checksum_str(contents:bytes) -> str: | ||
return hashlib.md5(contents).hexdigest() | ||
|
||
|
||
if __name__ == '__main__': | ||
filename = sys.argv[1] | ||
print(checksum_file(filename)) |