validata-py 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- validata_py-1.0.0/PKG-INFO +201 -0
- validata_py-1.0.0/README.md +176 -0
- validata_py-1.0.0/pyproject.toml +41 -0
- validata_py-1.0.0/setup.cfg +4 -0
- validata_py-1.0.0/validata_py.egg-info/PKG-INFO +201 -0
- validata_py-1.0.0/validata_py.egg-info/SOURCES.txt +7 -0
- validata_py-1.0.0/validata_py.egg-info/dependency_links.txt +1 -0
- validata_py-1.0.0/validata_py.egg-info/requires.txt +3 -0
- validata_py-1.0.0/validata_py.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: validata-py
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Conceal sensitive data — strings, emails, phones, numbers, cards, payloads, and free text — with a single clean API.
|
|
5
|
+
Author-email: Vishnu Sharma <vishnusharma180999@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/vishnusharma511/veildata
|
|
8
|
+
Project-URL: Issues, https://github.com/vishnusharma511/veildata/issues
|
|
9
|
+
Keywords: privacy,masking,PII,GDPR,data-security,anonymize,concealment
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Security
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
25
|
+
|
|
26
|
+
# veildata
|
|
27
|
+
|
|
28
|
+
> Conceal sensitive data in Python — strings, emails, phones, numbers, cards, dict payloads, and free text — with one import and one class.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install veildata
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Why veildata?
|
|
37
|
+
|
|
38
|
+
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.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Quick start
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from veildata import Veil
|
|
46
|
+
|
|
47
|
+
# Any string — control start point and length
|
|
48
|
+
Veil.cover("order-REF-99812", from_index=10)
|
|
49
|
+
# "order-REF-*****"
|
|
50
|
+
|
|
51
|
+
# Email — keeps @ and TLD, hides the rest
|
|
52
|
+
Veil.shield_email("alice@example.com")
|
|
53
|
+
# "a****@e******.com"
|
|
54
|
+
|
|
55
|
+
# Phone — non-digit characters survive
|
|
56
|
+
Veil.shield_phone("+91 98765-43210", expose_last=4)
|
|
57
|
+
# "+91 *****-43210"
|
|
58
|
+
|
|
59
|
+
# Integer — keep leading digits readable
|
|
60
|
+
Veil.shield_number(987654321, expose_first=3)
|
|
61
|
+
# "987******"
|
|
62
|
+
|
|
63
|
+
# Payment card — preserves spaces/dashes
|
|
64
|
+
Veil.shield_card("4111 1111 1111 1111")
|
|
65
|
+
# "**** **** **** 1111"
|
|
66
|
+
|
|
67
|
+
# Brazilian CPF
|
|
68
|
+
Veil.shield_cpf("123.456.789-01")
|
|
69
|
+
# "123.***.789-01"
|
|
70
|
+
|
|
71
|
+
# Brazilian CNPJ
|
|
72
|
+
Veil.shield_cnpj("12.345.678/0001-99")
|
|
73
|
+
# "12.***.***/**01-99"
|
|
74
|
+
|
|
75
|
+
# Entire dict payload — one call, any mix of types
|
|
76
|
+
Veil.shield_payload(
|
|
77
|
+
{
|
|
78
|
+
"name": "Priya Sharma",
|
|
79
|
+
"email": "priya@example.com",
|
|
80
|
+
"mobile": "+91-98765-43210",
|
|
81
|
+
"salary": 950000,
|
|
82
|
+
"pan": "ABCDE1234F",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "text",
|
|
86
|
+
"email": "email",
|
|
87
|
+
"mobile": "phone",
|
|
88
|
+
"salary": "zero",
|
|
89
|
+
"pan": "drop",
|
|
90
|
+
},
|
|
91
|
+
)
|
|
92
|
+
# {
|
|
93
|
+
# "name": "P**********a",
|
|
94
|
+
# "email": "p****@e******.com",
|
|
95
|
+
# "mobile": "+91-*****-43210",
|
|
96
|
+
# "salary": 0,
|
|
97
|
+
# "pan": "**********",
|
|
98
|
+
# }
|
|
99
|
+
|
|
100
|
+
# Auto-detect PII in free text
|
|
101
|
+
Veil.scrub_text("Reach me at dev@example.com or +91 9876543210")
|
|
102
|
+
# "Reach me at [EMAIL] or [PHONE]"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Full API
|
|
108
|
+
|
|
109
|
+
### `Veil.cover(text, char, from_index, length)`
|
|
110
|
+
|
|
111
|
+
| Param | Type | Default | Description |
|
|
112
|
+
|---|---|---|---|
|
|
113
|
+
| `text` | str | — | Input string |
|
|
114
|
+
| `char` | str | `"*"` | Replacement character |
|
|
115
|
+
| `from_index` | int | `0` | Start of concealment. Negative = from end |
|
|
116
|
+
| `length` | int \| None | `None` | Characters to conceal. `None` = to end |
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### `Veil.shield_email(email, char, reveal_user, reveal_host)`
|
|
121
|
+
|
|
122
|
+
| Param | Type | Default | Description |
|
|
123
|
+
|---|---|---|---|
|
|
124
|
+
| `email` | str | — | Email address |
|
|
125
|
+
| `char` | str | `"*"` | Replacement character |
|
|
126
|
+
| `reveal_user` | int | `1` | Leading chars of local part to keep |
|
|
127
|
+
| `reveal_host` | int | `1` | Leading chars of hostname to keep |
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### `Veil.shield_phone(phone, char, expose_last)`
|
|
132
|
+
|
|
133
|
+
| Param | Type | Default | Description |
|
|
134
|
+
|---|---|---|---|
|
|
135
|
+
| `phone` | str | — | Phone number (any format) |
|
|
136
|
+
| `char` | str | `"*"` | Replacement character |
|
|
137
|
+
| `expose_last` | int | `4` | Trailing digits to leave visible |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### `Veil.shield_number(value, char, expose_first)`
|
|
142
|
+
|
|
143
|
+
| Param | Type | Default | Description |
|
|
144
|
+
|---|---|---|---|
|
|
145
|
+
| `value` | int | — | Any integer |
|
|
146
|
+
| `char` | str | `"*"` | Replacement character |
|
|
147
|
+
| `expose_first` | int | `2` | Leading digits to leave visible |
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### `Veil.shield_card(card_number, char, expose_last)`
|
|
152
|
+
|
|
153
|
+
| Param | Type | Default | Description |
|
|
154
|
+
|---|---|---|---|
|
|
155
|
+
| `card_number` | str | — | Card number (formatted or plain) |
|
|
156
|
+
| `char` | str | `"*"` | Replacement character |
|
|
157
|
+
| `expose_last` | int | `4` | Trailing digits to leave visible |
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### `Veil.shield_cpf(cpf, char)` / `Veil.shield_cnpj(cnpj, char)`
|
|
162
|
+
|
|
163
|
+
Accept formatted or plain digit strings. Raise `ValueError` if the digit count is wrong.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### `Veil.shield_payload(data, blueprint, in_place)`
|
|
168
|
+
|
|
169
|
+
Blueprint strategy values:
|
|
170
|
+
|
|
171
|
+
| Strategy | Effect |
|
|
172
|
+
|---|---|
|
|
173
|
+
| `"text"` | Conceal middle, keep first and last character |
|
|
174
|
+
| `"email"` | Apply `shield_email` |
|
|
175
|
+
| `"phone"` | Apply `shield_phone` |
|
|
176
|
+
| `"card"` | Apply `shield_card` |
|
|
177
|
+
| `"zero"` | Replace number with `0` (or `"0"` for strings) |
|
|
178
|
+
| `"scramble"` | Replace each digit with a random digit, same length |
|
|
179
|
+
| `"drop"` | Replace entire value with asterisks |
|
|
180
|
+
|
|
181
|
+
Set `in_place=True` to mutate the original dict instead of returning a copy.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
### `Veil.scrub_text(text, scrub_emails, scrub_phones, scrub_cards, email_label, phone_label, card_label)`
|
|
186
|
+
|
|
187
|
+
Auto-detects PII with regex and replaces each match with a configurable label. No ML, no external libraries.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Running tests
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
python tests/test_veil.py
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# veildata
|
|
2
|
+
|
|
3
|
+
> Conceal sensitive data in Python — strings, emails, phones, numbers, cards, dict payloads, and free text — with one import and one class.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install veildata
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Why veildata?
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from veildata import Veil
|
|
21
|
+
|
|
22
|
+
# Any string — control start point and length
|
|
23
|
+
Veil.cover("order-REF-99812", from_index=10)
|
|
24
|
+
# "order-REF-*****"
|
|
25
|
+
|
|
26
|
+
# Email — keeps @ and TLD, hides the rest
|
|
27
|
+
Veil.shield_email("alice@example.com")
|
|
28
|
+
# "a****@e******.com"
|
|
29
|
+
|
|
30
|
+
# Phone — non-digit characters survive
|
|
31
|
+
Veil.shield_phone("+91 98765-43210", expose_last=4)
|
|
32
|
+
# "+91 *****-43210"
|
|
33
|
+
|
|
34
|
+
# Integer — keep leading digits readable
|
|
35
|
+
Veil.shield_number(987654321, expose_first=3)
|
|
36
|
+
# "987******"
|
|
37
|
+
|
|
38
|
+
# Payment card — preserves spaces/dashes
|
|
39
|
+
Veil.shield_card("4111 1111 1111 1111")
|
|
40
|
+
# "**** **** **** 1111"
|
|
41
|
+
|
|
42
|
+
# Brazilian CPF
|
|
43
|
+
Veil.shield_cpf("123.456.789-01")
|
|
44
|
+
# "123.***.789-01"
|
|
45
|
+
|
|
46
|
+
# Brazilian CNPJ
|
|
47
|
+
Veil.shield_cnpj("12.345.678/0001-99")
|
|
48
|
+
# "12.***.***/**01-99"
|
|
49
|
+
|
|
50
|
+
# Entire dict payload — one call, any mix of types
|
|
51
|
+
Veil.shield_payload(
|
|
52
|
+
{
|
|
53
|
+
"name": "Priya Sharma",
|
|
54
|
+
"email": "priya@example.com",
|
|
55
|
+
"mobile": "+91-98765-43210",
|
|
56
|
+
"salary": 950000,
|
|
57
|
+
"pan": "ABCDE1234F",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "text",
|
|
61
|
+
"email": "email",
|
|
62
|
+
"mobile": "phone",
|
|
63
|
+
"salary": "zero",
|
|
64
|
+
"pan": "drop",
|
|
65
|
+
},
|
|
66
|
+
)
|
|
67
|
+
# {
|
|
68
|
+
# "name": "P**********a",
|
|
69
|
+
# "email": "p****@e******.com",
|
|
70
|
+
# "mobile": "+91-*****-43210",
|
|
71
|
+
# "salary": 0,
|
|
72
|
+
# "pan": "**********",
|
|
73
|
+
# }
|
|
74
|
+
|
|
75
|
+
# Auto-detect PII in free text
|
|
76
|
+
Veil.scrub_text("Reach me at dev@example.com or +91 9876543210")
|
|
77
|
+
# "Reach me at [EMAIL] or [PHONE]"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Full API
|
|
83
|
+
|
|
84
|
+
### `Veil.cover(text, char, from_index, length)`
|
|
85
|
+
|
|
86
|
+
| Param | Type | Default | Description |
|
|
87
|
+
|---|---|---|---|
|
|
88
|
+
| `text` | str | — | Input string |
|
|
89
|
+
| `char` | str | `"*"` | Replacement character |
|
|
90
|
+
| `from_index` | int | `0` | Start of concealment. Negative = from end |
|
|
91
|
+
| `length` | int \| None | `None` | Characters to conceal. `None` = to end |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### `Veil.shield_email(email, char, reveal_user, reveal_host)`
|
|
96
|
+
|
|
97
|
+
| Param | Type | Default | Description |
|
|
98
|
+
|---|---|---|---|
|
|
99
|
+
| `email` | str | — | Email address |
|
|
100
|
+
| `char` | str | `"*"` | Replacement character |
|
|
101
|
+
| `reveal_user` | int | `1` | Leading chars of local part to keep |
|
|
102
|
+
| `reveal_host` | int | `1` | Leading chars of hostname to keep |
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### `Veil.shield_phone(phone, char, expose_last)`
|
|
107
|
+
|
|
108
|
+
| Param | Type | Default | Description |
|
|
109
|
+
|---|---|---|---|
|
|
110
|
+
| `phone` | str | — | Phone number (any format) |
|
|
111
|
+
| `char` | str | `"*"` | Replacement character |
|
|
112
|
+
| `expose_last` | int | `4` | Trailing digits to leave visible |
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### `Veil.shield_number(value, char, expose_first)`
|
|
117
|
+
|
|
118
|
+
| Param | Type | Default | Description |
|
|
119
|
+
|---|---|---|---|
|
|
120
|
+
| `value` | int | — | Any integer |
|
|
121
|
+
| `char` | str | `"*"` | Replacement character |
|
|
122
|
+
| `expose_first` | int | `2` | Leading digits to leave visible |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### `Veil.shield_card(card_number, char, expose_last)`
|
|
127
|
+
|
|
128
|
+
| Param | Type | Default | Description |
|
|
129
|
+
|---|---|---|---|
|
|
130
|
+
| `card_number` | str | — | Card number (formatted or plain) |
|
|
131
|
+
| `char` | str | `"*"` | Replacement character |
|
|
132
|
+
| `expose_last` | int | `4` | Trailing digits to leave visible |
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
### `Veil.shield_cpf(cpf, char)` / `Veil.shield_cnpj(cnpj, char)`
|
|
137
|
+
|
|
138
|
+
Accept formatted or plain digit strings. Raise `ValueError` if the digit count is wrong.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### `Veil.shield_payload(data, blueprint, in_place)`
|
|
143
|
+
|
|
144
|
+
Blueprint strategy values:
|
|
145
|
+
|
|
146
|
+
| Strategy | Effect |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `"text"` | Conceal middle, keep first and last character |
|
|
149
|
+
| `"email"` | Apply `shield_email` |
|
|
150
|
+
| `"phone"` | Apply `shield_phone` |
|
|
151
|
+
| `"card"` | Apply `shield_card` |
|
|
152
|
+
| `"zero"` | Replace number with `0` (or `"0"` for strings) |
|
|
153
|
+
| `"scramble"` | Replace each digit with a random digit, same length |
|
|
154
|
+
| `"drop"` | Replace entire value with asterisks |
|
|
155
|
+
|
|
156
|
+
Set `in_place=True` to mutate the original dict instead of returning a copy.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### `Veil.scrub_text(text, scrub_emails, scrub_phones, scrub_cards, email_label, phone_label, card_label)`
|
|
161
|
+
|
|
162
|
+
Auto-detects PII with regex and replaces each match with a configurable label. No ML, no external libraries.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Running tests
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
python tests/test_veil.py
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
MIT
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "validata-py"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Conceal sensitive data — strings, emails, phones, numbers, cards, payloads, and free text — with a single clean API."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [{ name = "Vishnu Sharma", email = "vishnusharma180999@gmail.com" }]
|
|
13
|
+
keywords = ["privacy", "masking", "PII", "GDPR", "data-security", "anonymize", "concealment"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.8",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Security",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
]
|
|
27
|
+
dependencies = []
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
dev = ["pytest>=7"]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/vishnusharma511/veildata"
|
|
34
|
+
Issues = "https://github.com/vishnusharma511/veildata/issues"
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.packages.find]
|
|
37
|
+
where = ["."]
|
|
38
|
+
include = ["veildata*"]
|
|
39
|
+
|
|
40
|
+
[tool.pytest.ini_options]
|
|
41
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: validata-py
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Conceal sensitive data — strings, emails, phones, numbers, cards, payloads, and free text — with a single clean API.
|
|
5
|
+
Author-email: Vishnu Sharma <vishnusharma180999@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/vishnusharma511/veildata
|
|
8
|
+
Project-URL: Issues, https://github.com/vishnusharma511/veildata/issues
|
|
9
|
+
Keywords: privacy,masking,PII,GDPR,data-security,anonymize,concealment
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Security
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
25
|
+
|
|
26
|
+
# veildata
|
|
27
|
+
|
|
28
|
+
> Conceal sensitive data in Python — strings, emails, phones, numbers, cards, dict payloads, and free text — with one import and one class.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install veildata
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Why veildata?
|
|
37
|
+
|
|
38
|
+
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.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Quick start
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from veildata import Veil
|
|
46
|
+
|
|
47
|
+
# Any string — control start point and length
|
|
48
|
+
Veil.cover("order-REF-99812", from_index=10)
|
|
49
|
+
# "order-REF-*****"
|
|
50
|
+
|
|
51
|
+
# Email — keeps @ and TLD, hides the rest
|
|
52
|
+
Veil.shield_email("alice@example.com")
|
|
53
|
+
# "a****@e******.com"
|
|
54
|
+
|
|
55
|
+
# Phone — non-digit characters survive
|
|
56
|
+
Veil.shield_phone("+91 98765-43210", expose_last=4)
|
|
57
|
+
# "+91 *****-43210"
|
|
58
|
+
|
|
59
|
+
# Integer — keep leading digits readable
|
|
60
|
+
Veil.shield_number(987654321, expose_first=3)
|
|
61
|
+
# "987******"
|
|
62
|
+
|
|
63
|
+
# Payment card — preserves spaces/dashes
|
|
64
|
+
Veil.shield_card("4111 1111 1111 1111")
|
|
65
|
+
# "**** **** **** 1111"
|
|
66
|
+
|
|
67
|
+
# Brazilian CPF
|
|
68
|
+
Veil.shield_cpf("123.456.789-01")
|
|
69
|
+
# "123.***.789-01"
|
|
70
|
+
|
|
71
|
+
# Brazilian CNPJ
|
|
72
|
+
Veil.shield_cnpj("12.345.678/0001-99")
|
|
73
|
+
# "12.***.***/**01-99"
|
|
74
|
+
|
|
75
|
+
# Entire dict payload — one call, any mix of types
|
|
76
|
+
Veil.shield_payload(
|
|
77
|
+
{
|
|
78
|
+
"name": "Priya Sharma",
|
|
79
|
+
"email": "priya@example.com",
|
|
80
|
+
"mobile": "+91-98765-43210",
|
|
81
|
+
"salary": 950000,
|
|
82
|
+
"pan": "ABCDE1234F",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "text",
|
|
86
|
+
"email": "email",
|
|
87
|
+
"mobile": "phone",
|
|
88
|
+
"salary": "zero",
|
|
89
|
+
"pan": "drop",
|
|
90
|
+
},
|
|
91
|
+
)
|
|
92
|
+
# {
|
|
93
|
+
# "name": "P**********a",
|
|
94
|
+
# "email": "p****@e******.com",
|
|
95
|
+
# "mobile": "+91-*****-43210",
|
|
96
|
+
# "salary": 0,
|
|
97
|
+
# "pan": "**********",
|
|
98
|
+
# }
|
|
99
|
+
|
|
100
|
+
# Auto-detect PII in free text
|
|
101
|
+
Veil.scrub_text("Reach me at dev@example.com or +91 9876543210")
|
|
102
|
+
# "Reach me at [EMAIL] or [PHONE]"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Full API
|
|
108
|
+
|
|
109
|
+
### `Veil.cover(text, char, from_index, length)`
|
|
110
|
+
|
|
111
|
+
| Param | Type | Default | Description |
|
|
112
|
+
|---|---|---|---|
|
|
113
|
+
| `text` | str | — | Input string |
|
|
114
|
+
| `char` | str | `"*"` | Replacement character |
|
|
115
|
+
| `from_index` | int | `0` | Start of concealment. Negative = from end |
|
|
116
|
+
| `length` | int \| None | `None` | Characters to conceal. `None` = to end |
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### `Veil.shield_email(email, char, reveal_user, reveal_host)`
|
|
121
|
+
|
|
122
|
+
| Param | Type | Default | Description |
|
|
123
|
+
|---|---|---|---|
|
|
124
|
+
| `email` | str | — | Email address |
|
|
125
|
+
| `char` | str | `"*"` | Replacement character |
|
|
126
|
+
| `reveal_user` | int | `1` | Leading chars of local part to keep |
|
|
127
|
+
| `reveal_host` | int | `1` | Leading chars of hostname to keep |
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### `Veil.shield_phone(phone, char, expose_last)`
|
|
132
|
+
|
|
133
|
+
| Param | Type | Default | Description |
|
|
134
|
+
|---|---|---|---|
|
|
135
|
+
| `phone` | str | — | Phone number (any format) |
|
|
136
|
+
| `char` | str | `"*"` | Replacement character |
|
|
137
|
+
| `expose_last` | int | `4` | Trailing digits to leave visible |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### `Veil.shield_number(value, char, expose_first)`
|
|
142
|
+
|
|
143
|
+
| Param | Type | Default | Description |
|
|
144
|
+
|---|---|---|---|
|
|
145
|
+
| `value` | int | — | Any integer |
|
|
146
|
+
| `char` | str | `"*"` | Replacement character |
|
|
147
|
+
| `expose_first` | int | `2` | Leading digits to leave visible |
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### `Veil.shield_card(card_number, char, expose_last)`
|
|
152
|
+
|
|
153
|
+
| Param | Type | Default | Description |
|
|
154
|
+
|---|---|---|---|
|
|
155
|
+
| `card_number` | str | — | Card number (formatted or plain) |
|
|
156
|
+
| `char` | str | `"*"` | Replacement character |
|
|
157
|
+
| `expose_last` | int | `4` | Trailing digits to leave visible |
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### `Veil.shield_cpf(cpf, char)` / `Veil.shield_cnpj(cnpj, char)`
|
|
162
|
+
|
|
163
|
+
Accept formatted or plain digit strings. Raise `ValueError` if the digit count is wrong.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### `Veil.shield_payload(data, blueprint, in_place)`
|
|
168
|
+
|
|
169
|
+
Blueprint strategy values:
|
|
170
|
+
|
|
171
|
+
| Strategy | Effect |
|
|
172
|
+
|---|---|
|
|
173
|
+
| `"text"` | Conceal middle, keep first and last character |
|
|
174
|
+
| `"email"` | Apply `shield_email` |
|
|
175
|
+
| `"phone"` | Apply `shield_phone` |
|
|
176
|
+
| `"card"` | Apply `shield_card` |
|
|
177
|
+
| `"zero"` | Replace number with `0` (or `"0"` for strings) |
|
|
178
|
+
| `"scramble"` | Replace each digit with a random digit, same length |
|
|
179
|
+
| `"drop"` | Replace entire value with asterisks |
|
|
180
|
+
|
|
181
|
+
Set `in_place=True` to mutate the original dict instead of returning a copy.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
### `Veil.scrub_text(text, scrub_emails, scrub_phones, scrub_cards, email_label, phone_label, card_label)`
|
|
186
|
+
|
|
187
|
+
Auto-detects PII with regex and replaces each match with a configurable label. No ML, no external libraries.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Running tests
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
python tests/test_veil.py
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|