DEV Community

Vishnu Sharma
Vishnu Sharma

Posted on

🔒 Stop Exposing Emails, Phones & Cards in Logs — Meet `validata-py`

🚀 I Built validata-py — A Lightweight Python Library for Masking Sensitive Data

While building backend systems, APIs, logging pipelines, and debugging tools, I kept running into the same problem:

Sensitive data was everywhere.

  • Phone numbers inside logs
  • Emails inside payloads
  • Card numbers in debug responses
  • PII leaking into monitoring systems
  • Raw customer data showing up during development

Every project ended up with custom masking utilities scattered across the codebase.

Some libraries handled emails.
Some handled cards.
Some only worked for regex scrubbing.

Nothing felt unified.

So I built validata-py — a lightweight Python package focused on one thing:

Simple, consistent, production-ready data masking.


✨ What is validata-py?

validata-py is a lightweight privacy-focused utility library for:

✅ Email masking
✅ Phone masking
✅ Card masking
✅ Payload anonymization
✅ Regex-based PII scrubbing
✅ CPF/CNPJ masking
✅ Generic string concealment

All with:

  • One import
  • One class
  • Zero dependencies
  • Clean API design

📦 Installation

pip install validata-py
Enter fullscreen mode Exit fullscreen mode

⚡ Quick Example

from validata_py import Veil

# Email masking
Veil.shield_email("alice@example.com")
# a****@e******.com

# Phone masking
Veil.shield_phone("+91 98765-43210")
# +91 *****-3210

# Card masking
Veil.shield_card("4111 1111 1111 1111")
# **** **** **** 1111

# PII scrubbing
Veil.scrub_text(
    "Contact me at dev@example.com or 9876543210"
)

# Contact me at [EMAIL] or [PHONE]
Enter fullscreen mode Exit fullscreen mode

🔥 One of My Favorite Features — Payload Masking

This became extremely useful while logging API payloads safely.

from validata_py import Veil

payload = {
    "name": "Priya Sharma",
    "email": "priya@example.com",
    "mobile": "+91-98765-43210",
    "salary": 950000,
}

blueprint = {
    "name": "text",
    "email": "email",
    "mobile": "phone",
    "salary": "zero",
}

Veil.shield_payload(payload, blueprint)
Enter fullscreen mode Exit fullscreen mode

Output:

{
    "name": "P**********a",
    "email": "p****@e******.com",
    "mobile": "+91-*****-3210",
    "salary": 0
}
Enter fullscreen mode Exit fullscreen mode

🧠 Why I Built It

I wanted a package that was:

  • Lightweight
  • Easy to use
  • Dependency-free
  • Consistent
  • Production-friendly
  • Formatting-safe

For example:

Veil.shield_phone("+91 98765-43210")
Enter fullscreen mode Exit fullscreen mode

preserves formatting automatically instead of returning broken unreadable strings.


🛠 Useful For

  • Backend APIs
  • Logging systems
  • GDPR/privacy workflows
  • Audit pipelines
  • Debug payload sanitization
  • Security tooling
  • Internal admin dashboards
  • Data anonymization

💡 Features

🔹 Generic String Concealment

Veil.cover("secret-token", from_index=3)
# sec*********
Enter fullscreen mode Exit fullscreen mode

🔹 Email Masking

Veil.shield_email("alice@example.com")
# a****@e******.com
Enter fullscreen mode Exit fullscreen mode

🔹 Phone Masking

Veil.shield_phone("+91 98765-43210")
# +91 *****-3210
Enter fullscreen mode Exit fullscreen mode

🔹 Card Masking

Veil.shield_card("4111 1111 1111 1111")
# **** **** **** 1111
Enter fullscreen mode Exit fullscreen mode

🔹 Free-Text PII Detection

Veil.scrub_text(
    "Call me at john@example.com"
)

# Call me at [EMAIL]
Enter fullscreen mode Exit fullscreen mode

🚀 Future Improvements

Some ideas I’m exploring:

  • PAN masking
  • Aadhaar masking
  • IBAN masking
  • Custom regex strategies
  • Async processing
  • FastAPI middleware integration
  • Structured log sanitizers

Would love ideas from the community.


🔗 Links

GitHub

https://github.com/vishnusharma511/validata-py

PyPI

https://pypi.org/project/validata-py/


❤️ Feedback Welcome

This is an early open-source release, and I’d genuinely love:

  • Feedback
  • Feature ideas
  • Bug reports
  • Contributions
  • Performance suggestions

If you work with APIs, logs, privacy tooling, or security systems, I’d love to hear how you would use it 🚀

Top comments (0)