core.hashing¶
Deterministic hashing utilities.
taskclf.core.hashing
¶
Deterministic hashing utilities for schema fingerprinting and PII obfuscation.
stable_hash(payload)
¶
Deterministic SHA-256 of payload, truncated to 12 hex chars.
Used for schema hashing (not for title hashing -- that uses the salted
variant :func:salted_hash).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
str
|
Arbitrary string to hash. |
required |
Returns:
| Type | Description |
|---|---|
str
|
First 12 hexadecimal characters of the SHA-256 digest. |
Source code in src/taskclf/core/hashing.py
salted_hash(payload, salt)
¶
Salted SHA-256 of payload, truncated to 12 hex chars.
Prepends salt to payload before hashing so the same input produces different digests under different salts. Intended for window-title and other PII obfuscation where reversibility must be infeasible even if the hash function is known.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
str
|
Arbitrary string to hash (e.g. a window title). |
required |
salt
|
str
|
A per-installation or per-session secret. |
required |
Returns:
| Type | Description |
|---|---|
str
|
First 12 hexadecimal characters of the SHA-256 digest. |
Source code in src/taskclf/core/hashing.py
keyed_digest(payload, secret, namespace)
¶
Return an HMAC-SHA256 digest for payload scoped by namespace.