13 lines
277 B
Python
13 lines
277 B
Python
"""File hashing utilities."""
|
|
|
|
import hashlib
|
|
from pathlib import Path
|
|
|
|
|
|
def sha256_of_file(path: Path) -> str:
|
|
h = hashlib.sha256()
|
|
with open(path, "rb") as f:
|
|
for chunk in iter(lambda: f.read(65536), b""):
|
|
h.update(chunk)
|
|
return h.hexdigest()
|