Skip to content

Commit

Permalink
Forgot to commit a script
Browse files Browse the repository at this point in the history
  • Loading branch information
harrisj committed Apr 20, 2022
1 parent 80b3100 commit cf533f9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pydantic = "*"
requests = "*"
python-slugify = "*"
dateparser = "*"
checksum = "*"

[dev-packages]

Expand Down
11 changes: 1 addition & 10 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions usda/checksum.py
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))

0 comments on commit cf533f9

Please sign in to comment.