mask-pii (Python)
Version: 0.2.0
A lightweight, customizable Python library for masking Personally Identifiable Information (PII) such as email addresses and phone numbers.
It is designed to be safe, fast, and easy to integrate into logging or data processing pipelines.
Official website: https://finitefield.org/en/oss/mask-pii Developed by: Finite Field, K.K.
Features
- Email Masking: Masks the local part while preserving the domain (e.g.,
a****@example.com). - Global Phone Masking: Detects international phone formats and masks all digits except the last 4.
- Customizable: Change the masking character (default is
*). - Zero Unnecessary Dependencies: Pure Python implementation.
Installation
From PyPI:
pip install mask-pii
From a local checkout:
pip install -e ./python
Usage
from mask_pii import Masker
masker = (
Masker()
.mask_emails()
.mask_phones()
.with_mask_char("#")
)
input_text = "Contact: alice@example.com or 090-1234-5678."
output = masker.process(input_text)
print(output)
# => "Contact: a####@example.com or ###-####-5678."
Configuration
The Masker class uses a builder-style API. By default, Masker() performs no masking (pass-through).
Builder Methods
| Method | Description | Default |
|---|---|---|
mask_emails() |
Enables detection and masking of email addresses. | Disabled |
mask_phones() |
Enables detection and masking of global phone numbers. | Disabled |
with_mask_char(char) |
Sets the character used for masking (e.g., "*", "#", "x"). |
"*" |
Masking Logic Details
Emails
- Pattern: Detects standard email formats.
- Behavior: Keeps the first character of the local part and the domain. Masks the rest of the local part.
- Example:
alice@example.com->a****@example.com - Short Emails: If the local part is 1 character, it is fully masked (e.g.,
a@b.com->*@b.com).
Phones (Global Support)
- Pattern: Detects sequences of digits that look like phone numbers (supports international
+81..., US(555)..., and hyphenated090-...). - Behavior: Preserves formatting (hyphens, spaces, parentheses) and the last 4 digits. All other digits are replaced.
- Examples:
090-1234-5678->***-****-5678+1 (800) 123-4567->+* (***) ***-456712345->*2345
Metadata
Release files for mask-pii 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mask_pii-0.2.0.tar.gz | 5.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mask_pii-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.4 kB
Release files / mask_pii-0.2.0.tar.gz
| Download URL | mask_pii-0.2.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a154e54fc4796c7429776e3759650f27f2c90779acb2d221085d8de8a269e12d
|
|
BLAKE2b-256 checksum How to use checksums |
c22c83b14bd47050ac734d5831de71925c935a08a0d0e26d9d9130c3df5cd95d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / mask_pii-0.2.0-py3-none-any.whl
| Download URL | mask_pii-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
157b6f665c736430e477ccb8569b2e42c083f0bef52c6d51aace60313fd18721
|
|
BLAKE2b-256 checksum How to use checksums |
121cc5514c42a9dab822cc42e6c48f6f173a6b3c702967fdd5f267a38a818410
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for mask-pii 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.