Redact PII from documents and data files before sharing: validated detection for emails, SSNs, cards, IBANs, phones and context-gated birth dates, four replacement strategies (replace, mask, keyed hash, consistent pseudonym), and a verification pass that catches metadata, tracked changes, and hidden parts. Use when someone asks to redact, scrub, anonymize, de-identify, or clean a document, spreadsheet, log, or export before sending it out, or to check whether a shared file still leaks personal data.
./install.sh pii-redaction-packname: pii_redaction_pack description: Redact PII from documents and data files before sharing: validated detection for emails, SSNs, cards, IBANs, phones and context-gated birth dates, four replacement strategies (replace, mask, keyed hash, consistent pseudonym), and a verification pass that catches metadata, tracked changes, and hidden parts. Use when someone asks to redact, scrub, anonymize, de-identify, or clean a document, spreadsheet, log, or export before sending it out, or to check whether a shared file still leaks personal data.
Make a file safe to hand to someone else, and prove it. The pack ships a tested stdlib-only scanner and redactor (bin/redact.py) plus a verification checklist (references/verification-checklist.md) that covers the places redaction usually fails: metadata, tracked changes, comments, embedded objects, and black-box-over-text PDF fakes.
Detection is pattern plus validation, not guesswork:
--names) and the tool finds every case-insensitive occurrence. Add house patterns (account numbers, case IDs) as regex lines with --extra.python3 bin/redact.py scan input.txt --names names.txt prints counts, line numbers, and masked previews as JSON. Exit code 2 means findings. Reviews show previews only, never full values, so the scan report itself does not become a leak.python3 bin/redact.py redact input.txt -o output.txt --strategy pseudonym --names names.txtreferences/verification-checklist.md (ExifTool plus qpdf re-linearize for PDFs, accept tracked changes and clear document properties for office files).python3 bin/redact.py verify output.txt --names names.txt must exit 0. For docx, xlsx, pptx, odt, pdf, and images, verify also scans the container parts and returns metadata warnings with exit code 2. Then work the rest of the checklist by eye.Replacement strategies, following the options NIST SP 800-188 lists for removing direct identifiers:
| Strategy | Output looks like | Use when | |---|---|---| | replace | [REDACTED:EMAIL] | Default. Recipient needs the shape of the document, not the values. | | mask | --0147, card keeps last 4 | Support and billing talks where the last 4 confirm identity. | | hash | [HASH:EMAIL:58645683fdf9f92d] | Joining records across files without sharing values. Keyed HMAC-SHA-256, key in PII_HASH_KEY. The tool refuses a bare unkeyed hash, which is easy to reverse for low-entropy values like SSNs. | | pseudonym | [EMAIL-1], [KNOWN_LITERAL-1] | Case notes and research text where the same person appears many times and the thread must stay readable. Consistent within one run. |
Worked example, tested end to end. Input line: SSN 078-05-1120. Card 4111 1111 1111 1111. The scan flags both (078-05-1120 passes SSA rules, the card passes Luhn). Pseudonym redaction gives SSN [US_SSN-1]. Card [CREDIT_CARD-1]. A lookalike line, Order total 1234 5678 9012 3456, is left untouched because that number fails Luhn.
publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e
No ratings yet — be the first to rate it.