Skip to main content

Privacy layer for AI prompts

Project description

🔐 PrivyLayer

Privacy layer for AI systems — protect sensitive data before it reaches AI.


🚀 Overview

PrivyLayer is a lightweight Python library that acts as a security layer between user input and AI models.

It detects sensitive information (PII), replaces it with secure placeholders, and restores it after the AI response — ensuring zero data exposure.


⚡ Why PrivyLayer?

Modern AI systems process user input directly, which may include:

  • 📱 Phone numbers
  • 📧 Emails
  • 🪪 Aadhaar / PAN
  • 🏦 Bank details

This creates a privacy risk.

👉 PrivyLayer solves this by introducing a reversible masking system.


🧠 How It Works

User Input
   ↓
PrivyLayer (detect + mask)
   ↓
AI Model
   ↓
PrivyLayer (restore)
   ↓
Final Output

✨ Features

  • 🔍 Detects sensitive data using regex patterns
  • 🔁 Reversible masking (no data loss)
  • 🧠 Smart tokenization system
  • ⚡ Fast and lightweight
  • 🇮🇳 India-specific PII support
  • 🔒 No data stored globally

📦 Installation

pip install privylayer

🛠️ Usage

🔐 Protect (Mask data)

from privylayer import protect

text = "My phone is 9876543210 and email is test@gmail.com"

mask , context , seen = main.find_p(text)

print(mask)

Output:

My phone is ⟦PII_PHONE_x1⟧ and email is ⟦PII_EMAIL_x2⟧

🔓 Restore (Unmask data)

from privylayer import restore

original = restore(masked, context)

print(original)

Output:

My phone is 9876543210 and email is test@gmail.com

🧩 Supported Data Types

  • 📱 Phone numbers (India)
  • 📧 Email addresses
  • 🪪 Aadhaar numbers
  • 🧾 PAN numbers
  • 🏦 IFSC codes

🔐 Token Format

PrivyLayer replaces sensitive data with structured tokens:

⟦PII_TYPE_ID⟧

Example:

⟦PII_PHONE_x1⟧
⟦PII_EMAIL_x2⟧

⚠️ Limitations

  • Regex-based detection (may not detect names accurately)
  • Does not validate Aadhaar checksum (yet)
  • Context must be preserved for restoration

🚀 Roadmap

  • AI-based name detection
  • Risk scoring system
  • Browser extension
  • API gateway version
  • Encryption-based token vault

🤝 Contributing

Contributions are welcome!

  • Fork the repo
  • Create a feature branch
  • Submit a pull request

📄 License

MIT License


👨‍💻 Author

Built by Nithish 🚀

Nithish's Portfolio

Nithish's Github


🌟 Vision

Making AI safe for everyone by protecting sensitive data at the source.


⭐ If you like this project, consider giving it a star!

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

privylayer-0.2.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

privylayer-0.2.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file privylayer-0.2.1.tar.gz.

File metadata

  • Download URL: privylayer-0.2.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for privylayer-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c311a91a8548188d50552556182b7e0fb491500b19bfb25f88280c5b01461d50
MD5 110fc45eacc3e90338879bc3a7b31926
BLAKE2b-256 ab3499e80c3d479bc978268b685223c790e7c5fc7576656e2b339e8d4ac1decc

See more details on using hashes here.

File details

Details for the file privylayer-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: privylayer-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for privylayer-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e326c9c5978004f636505361a935c7afa362c0a78c3f523cb8b8fce6a25605af
MD5 f5fc135033f170b9106a8b97be2a5a82
BLAKE2b-256 f7a8a08c185347d3d290f2adad9b4ae9d69ab4385ab4e851b5a54cc4068452ea

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