add hashing

This commit is contained in:
Maximilian Keßler 2022-02-07 22:01:43 +01:00
parent d08637eeba
commit f5c1a6c0c3

View file

@ -0,0 +1,12 @@
import hashlib
from pathlib import Path
# https://stackoverflow.com/a/3431838/16371376
def md5(file: Path):
hash_md5 = hashlib.md5()
with open(file, "rb") as f:
for block in iter(lambda: f.read(4096), b""):
hash_md5.update(block)
return hash_md5.hexdigest()