Skip to main content

Module pii

Module pii 

Source
Expand description

Normalization and hashing of personally identifiable information (PII) for audience uploads.

Every ad platform (Meta, Google Customer Match, TikTok DMP, LinkedIn DMP) requires user identifiers to be SHA-256 hashed after normalization. The normalization rules implemented here follow the strictest common contract so a single hasher works across all providers:

  • Emails: trim whitespace, lowercase.
  • Phones: digits only (strip +, spaces, dashes, parentheses), drop leading zeros. Callers should pass numbers with country code.

Values that already look like SHA-256 hex digests (64 hex chars) are passed through unchanged so callers can mix pre-hashed and raw data.

Functionsยง

hash_email
Normalize and hash an email address.
hash_phone
Normalize and hash a phone number.
normalize_email
Normalize an email address per the cross-platform contract: trim surrounding whitespace and lowercase.
normalize_phone
Normalize a phone number per the cross-platform contract: keep digits only and strip leading zeros.
sha256_hex
SHA-256 hash a value, returning the lowercase hex digest.