""" Content hashing helpers. A single canonical hash implementation is used everywhere page content is fingerprinted (Document nodes at ingestion time, /ingest/check-updates comparisons) so hashes computed at different times are comparable. """ import hashlib def compute_content_hash(content: str) -> str: """ Compute the canonical content hash for wiki page content. Args: content: Raw page content (markdown). None-safe: treated as "". Returns: Hex-encoded SHA-256 digest of the UTF-8 encoded content. Examples: >>> compute_content_hash("hello") '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824' """ return hashlib.sha256((content or "").encode("utf-8")).hexdigest()