Personal data
Personal data is information about a person who can be identified. NIST calls it PII: data that can identify someone alone, like an email, or combined, like a birth date plus a town. Lina signs up to a shop with five fields.
Security keeps data safe from attackers. Privacy asks more: should we collect this data at all, and do we use it only in ways the person expects? NIST notes that harm can come from processing that works exactly as designed.
Minimise in Python
The analytics team only wants to count sign-ups per plan and country. So line 2 lists the fields that purpose needs: plan and country. Name, email and birth date are not needed. This is data minimisation.
Line 4 builds a new dictionary from the KEEP fields only. Plan and country are copied across; name, email and birth date never are. Data that is never copied cannot leak from analytics, be misused there, or need deleting later.
Analytics still needs to tell sign-ups apart. Lines 5 to 7 replace the email with a pseudonym: an HMAC, a hash mixed with a secret key from the vault. The same email always gives the same tag; without the key, nobody can recompute it.
Line 8 returns the small record and it is saved in analytics: plan, country and a tag. The analytics system never holds a name, an email address or a birth date, so there is far less to protect there.
Personal data should be kept only as long as its purpose needs. This shop's rule: when an account closes, a scheduled job deletes the sign-up record and logs that it did. Lina closes her account, and her record is erased.
When it goes wrong
Months later, an alert fires: the analytics table is being copied out to the internet. This is the Detect part of incident response. The attacker gets plans, countries and tags, but no names, emails or birth dates.
Respond: stop the leak, then check your data map (your list of what data you hold, and where) to see whose data left. Is the vault key safe? Laws may require notice: the EU GDPR wants the regulator told within 72 hours where feasible.
Compliance
Compliance means showing you meet the rules that apply to you. NIST's Privacy Framework organises the work in five functions. Identify-P: map what data you hold and why. Govern-P: set policies, roles and legal duties. Control-P: manage data, like minimising and deleting it.
Communicate-P: tell people in plain words how their data is used, and listen. Protect-P: safeguard the data, like the keyed tags and the separate vault. Passing an audit is not the goal; keeping people from harm is.
What happens
;; step 1/11 · pii
PII information that can be used to distinguish
or trace a person's identity (NIST, OMB A-130)
alone name, email address
combined birth date + country + plan ...
rec["name"] "Lina"
rec["email"] "lina@x.test"
rec["born"] "1990-04-12"
rec["plan"] "pro"
rec["country"] "KW"
A pseudonym is not anonymous. Whoever holds the key can link the tag back to an email, so EU law still treats pseudonymised data as personal data. It lowers the risk; it does not remove it. The demo key is a short readable string so the example can be checked. A real key is random (for example 32 random bytes for HMAC-SHA-256), comes from a key vault and is never written in code.