hashlib is Python’s standard library module for applying secure hash algorithms such as SHA-256. Hashing turns sensitive values into deterministic codes that can support analytics without retaining those values in the working table. section 8.3.2
A practical email-hashing workflow:
- Use the digest as a deterministic customer key: repeated values match, while small input changes produce very different hashes. section 8.3.2
- Keep the original email and hash in a separate, restricted table, then remove the email from analytics transactions. section 8.3.2
Hashing email values
import hashlib def hash_email(email): return hashlib.sha256(email.encode()).hexdigest() transactions["email_hash"] = transactions["email"].apply(hash_email)

