Spaces:
lolab
/
Paused

ZONOS3-Mini / zonos3 /utils /hashing.py
Gatozu35's picture
Deploy ZONOS3 714a9cb-dirty
127a1e8 verified
Raw History Blame Contribute Delete
420 Bytes
"""SHA-256 hex digests of files and byte strings."""
from __future__ import annotations
import hashlib
import os
def sha256_file(path: str | os.PathLike, block: int = 1 << 22) -> str:
h = hashlib.sha256()
with open(path, "rb") as f:
while chunk := f.read(block):
h.update(chunk)
return h.hexdigest()
def sha256_bytes(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()