Skip to main content

India-first PII detection & redaction library

Project description

bharat-pii 🇮🇳

PyPI Python License CI

India-first PII detection & redaction library for GenAI pipelines.

bharat-pii helps detect and redact Indian-specific sensitive data (PAN, Aadhaar, UPI, IFSC, credit cards, etc.) before sending data to LLMs, logs, or analytics systems.

It is built with a regex-first, deterministic core and designed to be extensible with ML / Presidio adapters in the future.


✨ Features

  • 🇮🇳 India-first PII entities
  • ⚡ Fast & deterministic (regex + validation)
  • 🔒 Credit card detection with strict Luhn validation
  • 🔌 Extensible detector architecture
  • 🧱 LLM-safe (local by default)
  • 🧪 Fully testable
  • 📦 uv / PyPI friendly packaging

📌 Supported Entities

Entity Example
PAN ABCDE1234F
Aadhaar 2345 6789 0123
Indian Phone +91 9876543210
Credit Card 4111 1111 1111 1111
UPI ID rahul@upi
IFSC HDFC0001234

🛣️ Roadmap

Planned additions:

  • Email
  • Passport
  • Driving License
  • Entity severity & priority
  • Strict vs loose detection modes
  • Presidio (ML) adapter
  • CLI tool
  • PDF / OCR support

📦 Installation

Using pip:

pip install bharat-pii

Using uv:

uv pip install bharat-pii

🚀 Usage

Detect PII

from bharat_pii.api import detect

text = "Pay 500 to rahul@upi using card 4111 1111 1111 1111"
results = detect(text)
print(results)

Redact PII

from bharat_pii.api import redact

safe_text = redact("My IFSC is HDFC0001234 and Aadhaar is 2345 6789 0123")
print(safe_text)

Output:

My IFSC is ******1234 and Aadhaar is ********0123

🧠 Design Philosophy

  • Regex-first for precision and predictability
  • Validation where applicable (e.g. Luhn for cards)
  • Pluggable detector architecture
  • No cloud dependency
  • Minimal and stable API

Ideal for:

  • LLM pipelines
  • Fintech & healthcare systems
  • Logs & analytics
  • Internal tools
  • Compliance & PII redaction

🤝 Contributing

Contributions are welcome.
Please see CONTRIBUTING.md for guidelines.


📄 License

MIT License © Rahul Sharma

Project details


Download files

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

Source Distribution

bharat_pii-0.1.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

bharat_pii-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file bharat_pii-0.1.1.tar.gz.

File metadata

  • Download URL: bharat_pii-0.1.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for bharat_pii-0.1.1.tar.gz
Algorithm Hash digest
SHA256 57e2a5f293265aad877d038da266ccaf2f2b28ae2c6fa28875e84e764709e03e
MD5 c0b4321ed9c37d1d633e877502ccc2d9
BLAKE2b-256 5ab6a4e2997f3910225519d05aeea2c7b56fce397f3cf1930e3df2faf1613759

See more details on using hashes here.

File details

Details for the file bharat_pii-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bharat_pii-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad6ffc2b1c22479264e574784848c0c3368ad5ac3abf129ea00a0482060167a1
MD5 8575bc65c275e038308e663b9418c895
BLAKE2b-256 32a35ed46fe44b9190815beb77845557c6204ba888720cb1a170f22a66375664

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