Redacting personal data without wrecking the document
· 2 min read
At Jawafdehi we publish transcripts of court and police documents, and they're full of personal data: citizenship numbers, dates of birth, phone numbers, bank accounts. It has to come out before anything is published, without destroying what makes the record useful.
why patterns don't work
The obvious approach is a pattern: remove anything that looks like an ID number. But these documents are full of numbers that must survive. Case numbers, amounts, dates and section numbers all look like IDs to a regular expression. Remove too much and the record is useless. Remove too little and someone's citizenship number is public.
redact by label
So Likhit only removes a value when it sits next to a label that says what it is, in Nepali or English: the label for a citizenship number, then the number. A bare string of digits is left alone.
There are four levels: none, identifiers only, identifiers plus contact details, and strict, which also covers bank accounts, passport numbers and ages. Strict is the default, and saving a transcript redacts unless you explicitly turn it off. On 13 anti-corruption commission reports, strict removes 195 values.
what stays in
Some things are left in on purpose. PAN numbers identify businesses, not people, and are public. Names stay too. Treating the honorific श्री as a sign of a name gave 2,179 ambiguous matches, and an archive of corruption cases has to name the people in it anyway.
That's a policy decision as much as a technical one, and writing it into the code, with the reason next to it, matters as much as the matching.
a black box isn't redaction
Drawing a black box over text is the classic redaction mistake. The text is still in the file and copies out fine. Likhit removes the text itself, using the position of each character, and only then draws the box.
- Everything else that can hold text is cleared too: annotations, form fields, bookmarks and metadata.
- The file is saved fresh, never as an append. An appended save keeps the old content in the file.
- The result is read back to check that nothing redacted survived.
- Pages it can't redact safely are refused, like legacy-font pages and pure scans, rather than half-done.
in the pipeline
In the archive, every document now has four versions: the original and its transcript, and redacted copies of both. Only the redacted two are ever published. Documents stored before redaction existed were backfilled, so the rule holds for the whole archive, not just new arrivals.
what I took from it
- Precision matters as much as recall. A redactor that destroys case numbers won't stay switched on.
- Fail closed. Redact by default, and refuse what can't be done safely.
- Verify the output, not the code. Reading the file back is the only proof nothing leaked.