Skip to main content

Advanced PII detection and redaction library

Project description

PII Redaction Library 🔒

PyPI Version License: MIT Python Version

Advanced Personally Identifiable Information (PII) detection and redaction library with multi-format support.

PII Redaction Demo

Features ✨

  • 📄 Multi-format support: Text, DOCX, PDF
  • 🌍 Localization: English & Spanish (extensible)
  • 🔄 Redaction reversal via JSON logs
  • 🛡️ Detects:
    • Emails • Phones • SSNs • Credit Cards
    • Names • Organizations • Custom patterns
  • 🧩 Configurable regex patterns via YAML
  • 📊 Built-in validation for credit cards & SSNs

Installation 💻

pip install pii-redactor
python -m spacy download en_core_web_sm
python -m spacy download es_core_news_sm



Usage 🚀
Command Line Interface
# Basic redaction
pii-redact input.txt output.txt

# Spanish localization
pii-redact documento.docx redactado.docx --locale es_ES

# Custom config
pii-redact sensitive.pdf redacted.pdf --config custom_config.yml

# Redaction reversal
pii-redact redacted.txt original.txt --reverse redacted.log.json
Python API
from pii_redactor import PIIRedactor

redactor = PIIRedactor(locale='es_ES')
result = redactor.process_file("input.docx", "output.docx")

print(f"Redacted {len(result['emails'])} emails")
print(f"Detected {len(result['names'])} names")


Configuration ⚙️
Create custom_config.yml:

yaml
patterns:
  employee_id: '\bEMP-\d{5}\b'
locales:
  en_US:
    honorifics: ['Dr.', 'Madam']
    patterns:
      custom_phone: '\d{3}-\d{3}-\d{4}'


Supported Locales 🌐
Locale	Entities Detected	spaCy Model
en_US	Names, Orgs, US PII	en_core_web_sm
es_ES	Spanish names, DNI, IBAN	es_core_news_sm


Contributing 🤝
Fork the repository

Create your feature branch (git checkout -b feature/amazing-feature)

Commit changes (git commit -m 'Add amazing feature')

Push to branch (git push origin feature/amazing-feature)

Open a Pull Request

License 📄
This project is licensed under the MIT License - see LICENSE for details.

Acknowledgments
Built with ❤️ using spaCy

PDF handling by pdfplumber

Inspired by GDPR/CCPA compliance needs



---

### **LICENSE** (MIT)
```text
MIT License

Copyright (c) 2023 [Your Name or Organization]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Deployment Steps
Save these files in your project root:

README.md

LICENSE

Commit and push:

bash
git add README.md LICENSE
git commit -m "Add documentation and license"
git push origin main
Your GitHub repository will now show:

Professional README rendering

License visible in repo header

Clear usage instructions for visitors

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pii_redactor-0.1.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pii_redactor-0.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pii_redactor-0.1.tar.gz.

File metadata

  • Download URL: pii_redactor-0.1.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for pii_redactor-0.1.tar.gz
Algorithm Hash digest
SHA256 bdc3ed1a5c1fb2252dc918e3e3652b70494071b41c0a403a53884904838b5299
MD5 6874030637fa63e2cd3aa291462b234e
BLAKE2b-256 5d03cae7336c10657e51df5ff0e26f6cd379295dac61568ae3ffece9c150891d

See more details on using hashes here.

File details

Details for the file pii_redactor-0.1-py3-none-any.whl.

File metadata

  • Download URL: pii_redactor-0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for pii_redactor-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b2105f94767e5fafbcc8887b3673fbed655420c7bfee85d80d4efe6868dd5d5
MD5 59c8c4f7add851ae3af4986f4f247eef
BLAKE2b-256 6c6e42f559ff1e6602658e3a8f2653e982fbf16c7b649d66da801755e9d5bd40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page