Metadata-Version: 2.4
Name: validata-py
Version: 1.0.0
Summary: Conceal sensitive data — strings, emails, phones, numbers, cards, payloads, and free text — with a single clean API.
Author-email: Vishnu Sharma <vishnusharma180999@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/vishnusharma511/veildata
Project-URL: Issues, https://github.com/vishnusharma511/veildata/issues
Keywords: privacy,masking,PII,GDPR,data-security,anonymize,concealment
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"

# veildata

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

```bash
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

```python
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

```bash
python tests/test_veil.py
```

---

## License

MIT
