---
title: "Swap direct identifiers for keyed · Agent Wranglers"
url: https://agentwranglers.se/playbook/data-engineering/personal-data-in-the-warehouse/warehouse-pseudonyms
id: DEN-24
level: Recommended
updated: 2026-10-22
tokens: 989
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Swap direct identifiers for keyed pseudonyms

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Personal data in the warehouse](https://agentwranglers.se/playbook/data-engineering/personal-data-in-the-warehouse.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: DEN-24
- Level: Recommended
- Chapter: [Personal data in the warehouse](https://agentwranglers.se/playbook/data-engineering/personal-data-in-the-warehouse.md)
- Rule: Replace email addresses, names and account IDs with a keyed hash before they reach the warehouse, and keep the key outside it. Analysts join tables on the pseudonym.
- Check: A query over every text column in the warehouse finds no value containing `@` and no account ID as stored in the app. The key exists in the key service and in no warehouse table or pipeline setting.
- How: Use HMAC-SHA-256 with a key held as [Keep encryption keys in a key service](https://agentwranglers.se/playbook/infrastructure/configuration-and-secrets/key-management.md) describes. A plain hash of an email can be reversed by hashing a list of addresses. Pseudonymised data is still personal data, as the EDPB guidelines on pseudonymisation state, so the other rules in this chapter still apply. Looking a person up again for a support case goes through a separate tool that logs each lookup, as [Log who reads personal data](https://agentwranglers.se/playbook/data/personal-data/access-logging.md) says. Analytics events follow [Keep personal data out of events](https://agentwranglers.se/playbook/data/product-analytics/events-without-personal-data.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Python example

```python
import hashlib
import hmac

def pseudonym(key: bytes, identifier: str) -> str:
    return hmac.new(key, identifier.strip().lower().encode(), hashlib.sha256).hexdigest()
```

### JavaScript example

```js
import { createHmac } from 'node:crypto';

export const pseudonym = (key, identifier) =>
  createHmac('sha256', key).update(identifier.trim().toLowerCase()).digest('hex');
```

## Sources

- [GDPR Article 4(5), definition of pseudonymisation](https://eur-lex.europa.eu/eli/reg/2016/679/oj)
- [EDPB Guidelines 01/2025 on Pseudonymisation](https://www.edpb.europa.eu/our-work-tools/documents/public-consultations/2025/guidelines-012025-pseudonymisation_en)

## Related rules

- INF-28 [Keep encryption keys in a key service](https://agentwranglers.se/playbook/infrastructure/configuration-and-secrets/key-management.md) in Infrastructure and environments
- DAT-34 [Log who reads personal data](https://agentwranglers.se/playbook/data/personal-data/access-logging.md) in Data and databases
- DAT-51 [Keep personal data out of events](https://agentwranglers.se/playbook/data/product-analytics/events-without-personal-data.md) in Data and databases

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/data-engineering/personal-data-in-the-warehouse/warehouse-pseudonyms">Agent Wranglers data engineering playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Copy only the personal columns an analysis needs](https://agentwranglers.se/playbook/data-engineering/personal-data-in-the-warehouse/warehouse-minimisation.md)
- Next: [Erase people from the warehouse within the month](https://agentwranglers.se/playbook/data-engineering/personal-data-in-the-warehouse/warehouse-erasure.md)
- [Personal data in the warehouse](https://agentwranglers.se/playbook/data-engineering/personal-data-in-the-warehouse.md)
