Pseudonymisation
Pseudonymisation is the processing of personal data so that it can no longer be attributed to a specific individual without additional information, which is kept separately and protected.
Unlike anonymisation, pseudonymisation is reversible: the original identity can be recovered by combining the pseudonymised data with the separately-held mapping. Under the GDPR, pseudonymised data is still considered personal data, whereas properly anonymised data is not.
A common implementation replaces a direct identifier, such as an email address, with a token, hash, or surrogate key, while keeping the correspondence table isolated from the rest of the system.
<?php
function pseudonymize(string $userId, string $secret): string
{
// reversible only by whoever holds the mapping / secret
return hash_hmac('sha256', $userId, $secret);
}
$token = pseudonymize('user-1234', $secretKey);
?>