import hashlib import json def hash_any_object(var) -> str: """Deterministic sha256 over a JSON-encodable value. Replaces the older pickle-based hash: pickle is nondeterministic across Python versions / dict-ordering tweaks and pulls more attack surface than we need for a plain change-detection fingerprint.""" encoded = json.dumps(var, sort_keys=True, ensure_ascii=False, default=str) return hashlib.sha256(encoded.encode("utf-8")).hexdigest()