vla / dovla_cil /utils /hashing.py
anhtld's picture
Initial commit: DoVLA-CIL codebase (h=16 breakthrough)
adc02fa verified
Raw
History Blame Contribute Delete
305 Bytes
from __future__ import annotations
import hashlib
import json
from typing import Any
def stable_hash(payload: Any, *, length: int = 16) -> str:
encoded = json.dumps(payload, sort_keys=True, separators=(",", ":"), default=str).encode("utf-8")
return hashlib.sha256(encoded).hexdigest()[:length]