Skip to content

hash

hash replaces each entity with a SHA hash of its value. Because the hash is deterministic for the same value and operator params, it is useful for analytics joins on de-identified data while reducing direct exposure of the original value.

ParameterTypeDefaultDescription
hash_typeSTRING"sha256"Hash algorithm: "sha256" or "sha512".
saltSTRING""Optional salt prepended to each value before hashing (hash(salt + value)). Use a secret, stable salt to reduce rainbow-table and common-value matching risk while staying deterministic for a given salt + value pair.
entity_collapseBOOLEANfalseOperator-level opt-in for full identity collapse. When request-level entity_collapse is enabled, aliases in the same collapsed group share one hash.
SELECT app_public.mask(
'Contact: john.smith@acme.com',
OBJECT_CONSTRUCT(
'entity_config', OBJECT_CONSTRUCT(
'EMAIL_ADDRESS', OBJECT_CONSTRUCT(
'operator', 'hash',
'operator_params', OBJECT_CONSTRUCT('hash_type', 'sha256')
)
)
)
);
-- Contact: 83f1c2b4e0a9d8f7... (64-character SHA-256 hex digest)
OBJECT_CONSTRUCT(
'entity_config', OBJECT_CONSTRUCT(
'EMAIL_ADDRESS', OBJECT_CONSTRUCT(
'operator', 'hash',
'operator_params', OBJECT_CONSTRUCT(
'hash_type', 'sha256',
'salt', 'my-dataset-salt-2024'
)
)
)
)

Example — collapse aliases before hashing

Section titled “Example — collapse aliases before hashing”

By default, hash normalizes small formatting differences before hashing. To hash aliases such as "Sarah Chen", "Chen", and "Dr. Chen" to the same digest, enable request-level entity_collapse and opt the operator into full collapse:

OBJECT_CONSTRUCT(
'entity_collapse', 0.5,
'entity_config', OBJECT_CONSTRUCT(
'PERSON', OBJECT_CONSTRUCT(
'operator', 'hash',
'operator_params', OBJECT_CONSTRUCT(
'hash_type', 'sha256',
'entity_collapse', TRUE
)
)
)
)
  • Analytics on de-identified data: count distinct users, join across datasets, and aggregate by customer with less direct exposure of raw identifiers.
  • Cross-dataset linking: the same email gets the same hash when the value, hash type, salt, and collapse behavior match, enabling joins without sharing the raw value.
  • Pseudonymous identifiers: include salted hashes in controlled operational datasets when support or debugging workflows need a stable reference to the same entity.
  • SHA hashing is not reversible through Agent Mask. However, deterministic hashes can still be linkable and guessable when the source value is common or known.
  • Hashes are pseudonymous identifiers, not anonymous data. They may remain sensitive under your organization’s policies or applicable privacy regulations, especially when they can be joined back to people or records.
  • If an attacker can guess the original value, such as a common email address, they can hash the guess and compare it. Hash is not protection against a known-plaintext attack by itself.
  • Use salt to reduce rainbow-table and common-value matching risk. Keep the salt secret, restrict access to it, and keep it consistent only across datasets that intentionally need joinability.
  • If operator_params.entity_collapse=true, all aliases in a collapsed group hash from the canonical value chosen by the collapse step.
  • For reversible re-identification, use encrypt instead.
  • encrypt — reversible with a key.
  • faker — realistic synthetic values.