Thalweg · API reference ← Main docs

make_sha2_salted_udf

Function make_sha2_salted_udf 

Source
pub fn make_sha2_salted_udf(salt: Option<&str>) -> ScalarUDF
Expand description

sha2_salted(col, prefix_len) — one-way pseudonym generator for producing a hashed id to share with third parties.

SECURITY (fail-closed): the anonymisation guarantee depends ENTIRELY on a secret, high-entropy salt. An unsalted, empty-salt, or weakly-salted SHA-256 of an enumerable id is trivially reversible by the recipient, defeating the pseudonym. Therefore, when the configured salt is not SaltStrength::Usable this UDF returns NULL for EVERY row rather than emitting a reversible hash. The verdict is computed once at construction time.

With a usable salt: salt-prefixed SHA-256, lowercase hex, with the prefix_len truncation semantics. Null/absent inputs always map to NULL.

Note: the salt is trimmed before hashing, so a salt with surrounding whitespace produces a different digest than the untrimmed value would.