A library for masking PII (Personally Identifiable Information) in text
Project description
PII Data Masker
A Python library for masking Personally Identifiable Information (PII) in text data.
Installation
pip install piidata-masker
Basic Usage
from piidata_masker import PIIMasker
# Create a masker
masker = PIIMasker()
# Mask email
email = masker.mask_email("john.doe@example.com")
print(email) # jo******@example.com
# Mask phone
phone = masker.mask_phone("555-123-4567")
print(phone) # ******4567
# Mask text with multiple PII
text = "Hello, this is John Smith from ABC Corporation. You can reach me at john.smith@company.com or call me at 555-123-4567. For urgent matters, try my mobile at +1-800-555-9876 or send an email to j.s@corp.co. Our customer service team can be contacted at support@helpdesk.example.org or by calling 1234567890. If you need to reach our international office, dial +44-207-123-4567 or email london.office@global-company.co.uk. For quick questions, you might also try reaching out to sarah.johnson123@marketing.dept.com at 9876543210, or our CEO directly at ceo@company.net (phone: +33-1-23-45-67-89). Emergency contact: a@b.c at 5551234567. Don't forget to CC operations@facility.management.co on important emails, and their direct line is 555.987.6543.
"
masked = masker.mask_text(text)
print(masked)
# Hello, this is John Smith from ABC Corporation. You can reach me at joh#######@co#####.com or call me at #####34567. For urgent matters, try my mobile at ######59876 or send an email to j#@co##.co. Our customer service team can be contacted at sup####@he######.example.org or by calling #####67890. If you need to reach our international office, dial #######34567 or email lon##########@gl############.co.uk. For quick questions, you might also try reaching out to sar#############@ma#######.dept.com at #####43210, or our CEO directly at c#@co#####.net (phone: ######56789). Emergency contact: a#@b.c at #####34567. Don't forget to CC ope#######@fa######.management.co on important emails, and their direct line is #####76543.
Custom Configuration
from piidata_masker import MaskConfig
config = MaskConfig(
email_show_chars=3, # Show first 3 chars of email
phone_show_chars=4, # Show last 4 digits
mask_char="#", # Use # for masking
mask_domains=True # Also mask domains
)
masker = PIIMasker(config)
print(masker.mask_email("john.doe@example.com"))
# Output: joh#####@ex#####.com
print(masker.mask_phone("555-123-4567"))
#output: ******4567
print(masker.mask_text("Hello, this is John Smith from ABC Corporation. You can reach me at john.smith@company.com or call me at 555-123-4567. For urgent matters, try my mobile at +1-800-555-9876 or send an email to j.s@corp.co."))
#output:Hello, this is John Smith from ABC Corporation. You can reach me at joh#######@co#####.com or call me at #####34567. For urgent matters, try my mobile at ######59876 or send an email to j#@co##.co
Features
-
Email Masking:
- Configurable visible characters
- Optional domain masking
- Preserves email format
-
Phone Number Masking:
- Multiple formats supported
- Configurable visible digits
- Handles international formats
-
Text Processing:
- Masks multiple PII types
- Preserves text structure
- Non-destructive processing
License
MIT License - See LICENSE file for details.
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
piidata_masker-1.0.4.tar.gz
(6.5 kB
view details)
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 piidata_masker-1.0.4.tar.gz.
File metadata
- Download URL: piidata_masker-1.0.4.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddfbb7a657d1a89c72a6e000883123bac649f8a505478cbf530865371f67bff3
|
|
| MD5 |
4021d6748aa8451087a44eea0e4878da
|
|
| BLAKE2b-256 |
eb7b426665380339d1adef67c3d3185b4774bed36be601670650106265cf6d18
|
File details
Details for the file piidata_masker-1.0.4-py3-none-any.whl.
File metadata
- Download URL: piidata_masker-1.0.4-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca40aad3888be54ded5cb0290c40851dfdfd7665fb37617b62a98e7816dc809d
|
|
| MD5 |
fffbb0ce77e543c3fa3f1b69fd189226
|
|
| BLAKE2b-256 |
972e86760f8a679e25eb99bc4d051fe7dacba49c5f062097a4da4ec73bcca5f4
|