INNER CODE UNIT · Python
now
i3T4AN/KADATH · kadath/engine.py:35
def now() -> str:
return datetime.now(UTC).isoformat()
def digest(value: str) -> str:
return hashlib.sha256(value.encode()).hexdigest()
def hash_file(path: Path) -> tuple[int, str]:
hasher = hashlib.sha256(); size = 0
with path.open("rb") as stream:
while True:
chunk = stream.read(1024 * 1024)
if not chunk: break
size += len(chunk); hasher.update(chunk)
return size, hasher.hexdigest()