Spaces:
Sleeping
Sleeping
| from __future__ import annotations | |
| import hashlib | |
| from pathlib import Path | |
| def sha256_file(path: str | Path, chunk_size: int = 1024 * 1024) -> str: | |
| digest = hashlib.sha256() | |
| with Path(path).open("rb") as handle: | |
| while chunk := handle.read(chunk_size): | |
| digest.update(chunk) | |
| return digest.hexdigest() | |
| def sha256_bytes(data: bytes) -> str: | |
| return hashlib.sha256(data).hexdigest() | |