Two ways to hide Sam
A researcher wants to study canteen choices. Option one: remove names and emails, and turn ages into bands. Nobody can tell who is who. Option two: swap each name for a code, and keep a secret list that links codes to names.
Both hide Sam. Only one is truly anonymous.
Key words
| Word | What it means |
|---|---|
| Personal data | Information about a living person who can be identified. |
| Anonymisation | Changing data so nobody can be identified from it, by anyone. |
| Pseudonymisation | Swapping identifiers for codes. A separate key can link them back. |
| Hashing | A one-way scramble that turns text into a fixed code. |
| Salt | Extra secret text added before hashing so guesses fail. |
| Banding | Replacing an exact number with a range, such as an age band. |
| Primary use | Using data for the reason it was first collected. |
| Secondary use | Using data for a new reason after it was collected. |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can anonymise and pseudonymise data in Python, and say which to use for a primary or a secondary use.
Starter: last lesson
Have a go
Starter: last lesson
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Anonymisation
Anonymisation changes data so that nobody can be identified, even with extra effort. If that is true, the data is no longer personal data and data protection law does not apply to it.
Remove direct identifiers. Use bands, not exact values. Hide small groups. Then ask: could someone still work out who it is?
Pseudonymisation
Pseudonymisation swaps a name for a code. Data with codes is still personal data, because the key can link the code back to a person.
Keep the key somewhere else, with tight access. Use a salt when you hash. Without one, an attacker can guess common names and hash them too.
Anonymised or pseudonymised
| Question | Anonymised | Pseudonymised |
|---|---|---|
| Can it be linked back to a person? | No | Yes, with the key |
| Is it personal data? | No, if done well | Yes |
| Good for | Secondary use, sharing, public reports | Work that needs to link records over time |
| What to protect | Check nobody can be re-identified | The key and the salt |
The cells students fill in are left blank in this preview.
Try it: a salted code for a name
import hashlib
salt = "x9"
for name in ["Sam", "Alex", "Sam"]:
code = hashlib.sha256((salt + name).encode()).hexdigest()[0:8]
print(name, "->", code)
Check: which one?
Have a go
Check: which one?
4 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.