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()