#215 Data governance 5.5 min
Pseudonymise or Anonymise? Test It on Fake Data
I hashed a thousand emails. A list of guesses gave all of them back. Then I dropped the names, and 998 rows were still unique.
Hide the salt from the attacker
Copy the code folder first. In pseudo.py, change the salted line in SCHEMES so the attacker uses plain instead of salted, as if the attacker never saw the salt. Predict the three results, then run python pseudo.py. When I ran it, plain recovered 1000 of 1000, and salted and keyed both recovered 0 of 1000. Explain in one sentence why the video's version recovered all 1000 for salted. Undo this change afterwards, so the next exercises give the numbers they state.
A hint
In the video the salt is stored with the data, so the attacker can add it to every guess.
Shrink the guess list
In pseudo.py, change the guesses line so it only uses the first 20 first names, by writing FIRST[:20] in place of FIRST. Predict whether the plain and salted results stay at 1000, then run it. When I ran it, plain and salted each recovered 506 of 1000 and keyed still recovered 0.
A hint
The guess list now holds fewer addresses than the data contains.
Raise the smallest allowed group
In kanon.py, change the number 5 in the safe line to 10. Before you run python kanon.py, predict whether more or fewer rows will remain in the groups removed line. When I ran it, 778 rows remained and the smallest group was k = 10, but the riskiest group of 13 still showed asthma 77%. Why does the last line not change? Undo this change afterwards, so the next exercises give the numbers they state.
A hint
The riskiest group has 13 rows, which is above both thresholds.
Drop a column from the key
In kanon.py, remove sex from both the raw and the coarse functions, so each returns only age and postcode. Predict how the rows alone figure changes for the age band and postcode district case, then run it. When I ran it, rows alone became 0, the smallest group was k = 2, and the riskiest group was 5 rows with diabetes 60%. Write one sentence on what that tells you about the choice of columns.
A hint
Fewer columns in the key make groups bigger, so fewer rows are alone.
These tasks are for you to try on your own machine. Nothing is checked or saved.
What this does not show
Made-up data. The guess list holds every possible email and the join uses the same thousand people, so real results will differ. Not legal advice; the ICO guidance is under review.
Up next in Data governance
More in Data governance
- #203 A Business Glossary in YAML With Four Python Checks
- #204 Tag PII Columns in Python, Including a False Positive
- #205 Column-Level Lineage from SQL with SQLGlot
- #208 Right to Erasure Across a Pipeline: Delete, Scan, Restore
- #209 UK GDPR Data Map as Code: A Practical Checklist
- #210 A Data Quality Scorecard That Shows a Hidden Failure
