A package to anonymize sensitive data in text.
Project description
Privacify
Privacify is a Python project for anonymizing sensitive information in text and datasets. It provides simple tools to mask, hash, or remove personally identifiable information (PII) such as emails, credit card numbers, and phone numbers, making your data safe for sharing, analysis, or compliance with privacy regulations.
Features
- Flexible anonymization: Detects and replaces emails, credit card numbers, and phone numbers.
- Customizable tags: Choose how anonymized data is represented.
- Easy integration: Use as a Python module or script.
- Compliance: Helps meet GDPR, HIPAA, and other privacy requirements.
How It Works
The main function processes your text by:
- Identifying emails, credit card numbers, and phone numbers using regular expressions.
- Replacing them with customizable tags (e.g.,
[EMAIL],[CREDIT_CARD],[PHONE]). - Returning the anonymized text.
Example: Selective Anonymization
Parameter Overview
The anonymize_text function supports the following parameters to control the anonymization process:
| Parameter | Type | Default | Description |
|---|---|---|---|
anonymize_email |
bool | True |
Anonymize email addresses if set to True. |
anonymize_credit_card |
bool | True |
Anonymize credit card numbers if set to True. |
anonymize_phone |
bool | True |
Anonymize phone numbers if set to True. |
email_tag |
str | [EMAIL] |
Placeholder for anonymized email addresses. |
credit_card_tag |
str | [CREDIT_CARD] |
Placeholder for anonymized credit card numbers. |
phone_tag |
str | [PHONE] |
Placeholder for anonymized phone numbers. |
These parameters let you flexibly control which types of data are anonymized and how they are represented.
from Privacify import anonymize_text
text = """
Meine Kreditkarte ist 4111 1111 1111 1111 und die von Max ist 5500-0000-0000-0004.
Seine Nummer ist 0123 4567890. und meine +49 123 4567890. Die Zahlung war 123,52€
Bitte auf der Folgenden E-Mail antworten: hello.world@gmail.com
"""
# Only anonymize credit cards and phone numbers, leave emails unchanged
cleaned_text = anonymize_text(
text,
anonymize_email=False,
anonymize_credit_card=True,
anonymize_phone=True
)
print(cleaned_text)
Output:
Meine Kreditkarte ist [CREDIT_CARD] und die von Max ist [CREDIT_CARD].
Seine Nummer ist [PHONE]. und meine [PHONE]. Die Zahlung war 123,52€
Bitte auf der Folgenden E-Mail antworten: hello.world@gmail.com
from Privacify import anonymize_text
text = """
Meine Kreditkarte ist 4111 1111 1111 1111 und die von Max ist 5500-0000-0000-0004.
Seine Nummer ist 0 123 4567890.
Bitte auf der Folgenden E-Mail antworten: hello.world@gmail.com
"""
cleaned_text = anonymize_text(text)
print(cleaned_text)
Output:
Meine Kreditkarte ist [CREDIT_CARD] und die von Max ist [CREDIT_CARD].
Seine Nummer ist [PHONE].
Bitte auf der Folgenden E-Mail antworten: [EMAIL]
License
MIT License
Feel free to contribute or open issues for feature requests!
Project details
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 privacify-0.3.4.tar.gz.
File metadata
- Download URL: privacify-0.3.4.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
637429faed889506c1847f2211da88501e20d503041c4b619fd975fec480643c
|
|
| MD5 |
0da67dff23cc6189ea67cee37f2101fe
|
|
| BLAKE2b-256 |
1626a7354e39ab139227b75f549f4a6d2176ad529a59ec3f85b75dac57b605b0
|
File details
Details for the file privacify-0.3.4-py3-none-any.whl.
File metadata
- Download URL: privacify-0.3.4-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b734560210ba63a165ba9022e190f43c3d1c257d9acf107d50a0c1e96a49d89
|
|
| MD5 |
9825d95cb3b2a57061c26f81ade8baed
|
|
| BLAKE2b-256 |
ecb4bdd75d0f52af0941f1f87dc48cddedcb98d23321e7626d7c73e90e9c572c
|