Skip to main content

Conceal sensitive data — strings, emails, phones, numbers, cards, payloads, and free text — with a single clean API.

Project description

veildata

Conceal sensitive data in Python — strings, emails, phones, numbers, cards, dict payloads, and free text — with one import and one class.

pip install veildata

Why veildata?

Most masking libraries handle one data type. You end up installing three packages, learning three APIs, and writing glue code between them. veildata puts everything in one place with consistent arguments and zero dependencies.


Quick start

from veildata import Veil

# Any string — control start point and length
Veil.cover("order-REF-99812", from_index=10)
# "order-REF-*****"

# Email — keeps @ and TLD, hides the rest
Veil.shield_email("alice@example.com")
# "a****@e******.com"

# Phone — non-digit characters survive
Veil.shield_phone("+91 98765-43210", expose_last=4)
# "+91 *****-43210"

# Integer — keep leading digits readable
Veil.shield_number(987654321, expose_first=3)
# "987******"

# Payment card — preserves spaces/dashes
Veil.shield_card("4111 1111 1111 1111")
# "**** **** **** 1111"

# Brazilian CPF
Veil.shield_cpf("123.456.789-01")
# "123.***.789-01"

# Brazilian CNPJ
Veil.shield_cnpj("12.345.678/0001-99")
# "12.***.***/**01-99"

# Entire dict payload — one call, any mix of types
Veil.shield_payload(
    {
        "name":   "Priya Sharma",
        "email":  "priya@example.com",
        "mobile": "+91-98765-43210",
        "salary": 950000,
        "pan":    "ABCDE1234F",
    },
    {
        "name":   "text",
        "email":  "email",
        "mobile": "phone",
        "salary": "zero",
        "pan":    "drop",
    },
)
# {
#   "name":   "P**********a",
#   "email":  "p****@e******.com",
#   "mobile": "+91-*****-43210",
#   "salary": 0,
#   "pan":    "**********",
# }

# Auto-detect PII in free text
Veil.scrub_text("Reach me at dev@example.com or +91 9876543210")
# "Reach me at [EMAIL] or [PHONE]"

Full API

Veil.cover(text, char, from_index, length)

Param Type Default Description
text str Input string
char str "*" Replacement character
from_index int 0 Start of concealment. Negative = from end
length int | None None Characters to conceal. None = to end

Veil.shield_email(email, char, reveal_user, reveal_host)

Param Type Default Description
email str Email address
char str "*" Replacement character
reveal_user int 1 Leading chars of local part to keep
reveal_host int 1 Leading chars of hostname to keep

Veil.shield_phone(phone, char, expose_last)

Param Type Default Description
phone str Phone number (any format)
char str "*" Replacement character
expose_last int 4 Trailing digits to leave visible

Veil.shield_number(value, char, expose_first)

Param Type Default Description
value int Any integer
char str "*" Replacement character
expose_first int 2 Leading digits to leave visible

Veil.shield_card(card_number, char, expose_last)

Param Type Default Description
card_number str Card number (formatted or plain)
char str "*" Replacement character
expose_last int 4 Trailing digits to leave visible

Veil.shield_cpf(cpf, char) / Veil.shield_cnpj(cnpj, char)

Accept formatted or plain digit strings. Raise ValueError if the digit count is wrong.


Veil.shield_payload(data, blueprint, in_place)

Blueprint strategy values:

Strategy Effect
"text" Conceal middle, keep first and last character
"email" Apply shield_email
"phone" Apply shield_phone
"card" Apply shield_card
"zero" Replace number with 0 (or "0" for strings)
"scramble" Replace each digit with a random digit, same length
"drop" Replace entire value with asterisks

Set in_place=True to mutate the original dict instead of returning a copy.


Veil.scrub_text(text, scrub_emails, scrub_phones, scrub_cards, email_label, phone_label, card_label)

Auto-detects PII with regex and replaces each match with a configurable label. No ML, no external libraries.


Running tests

python tests/test_veil.py

License

MIT

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

validata_py-1.0.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

validata_py-1.0.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file validata_py-1.0.0.tar.gz.

File metadata

  • Download URL: validata_py-1.0.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for validata_py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f78dd28309296c7fef90ac16d0ad1ab520edf19beb09809557ee685acaaf310a
MD5 7f4e7aee7f3b8c5cc43aca714fda1b56
BLAKE2b-256 bea1d1509e5ada827858b671ce628b6a50c7ae2405e0a33581fd20264ceb3d7a

See more details on using hashes here.

File details

Details for the file validata_py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: validata_py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for validata_py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 250917fba6963a38e87a4a6d26967d3625a61dc9bfd397cf94ea502c6d1fb091
MD5 0cbf150899f2deabea0162d65e8567cf
BLAKE2b-256 ddf5d7f0021df80f73e3a34562e5ef3b3a667a8ed862018174ce6fdefb72550c

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