India-first PII detection & redaction library
Project description
bharat-pii 🇮🇳
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:
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bharat_pii-0.1.2.tar.gz.
File metadata
- Download URL: bharat_pii-0.1.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
307ed22c3af6b8cb1fc5afab93de22ae56fec7b89e66ff6cc850b53a3469fb03
|
|
| MD5 |
b122a4d0ad32c9776fa9b32a2b76464e
|
|
| BLAKE2b-256 |
3ed562a7ed69a0d4fa4f056219db735a9701f4209d2799a6fd326652b4ff2841
|
File details
Details for the file bharat_pii-0.1.2-py3-none-any.whl.
File metadata
- Download URL: bharat_pii-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89df93e8cedab863271b441811b4cc3d545eba7a37eb05a81fd7bc69254c202f
|
|
| MD5 |
dafe8613a32c94e6dcc68886c9a2f2a0
|
|
| BLAKE2b-256 |
9954a3a374b6bf1dad24abdcf923ea9becf20478ae8336b4d2305c518daac8ea
|