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
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 validata_py-1.0.1.tar.gz.
File metadata
- Download URL: validata_py-1.0.1.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3af82f627a719ee729b99bc7ee57f85d66a668c89f3c56eb872a0b3034c7cad
|
|
| MD5 |
4d344c78005a33ea6b872c05eb23b267
|
|
| BLAKE2b-256 |
2c8f28090f7827bf95d7bfdba378a83864ae39ee4140a1394f8b247ad332a6e5
|
File details
Details for the file validata_py-1.0.1-py3-none-any.whl.
File metadata
- Download URL: validata_py-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c15c995b882ba17a58fd89ee02c0fe11e7df6e739287730028893ee88acb3b78
|
|
| MD5 |
419b862f399cd970b19f8348d9c43704
|
|
| BLAKE2b-256 |
dc88fbc640197aa21a76b0086bf5e15bf989c77502d4773d8c9cb8f8f8998039
|