Skip to main content

A package to anonymize sensitive data in text.

Project description

Privacify

Data Anonymizer 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:

  1. Identifying emails, credit card numbers, and phone numbers using regular expressions.
  2. Replacing them with customizable tags (e.g., [EMAIL], [CREDIT_CARD], [PHONE]).
  3. 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 data_anonymizer 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 data_anonymizer 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

privacify-0.2.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

privacify-0.2.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file privacify-0.2.0.tar.gz.

File metadata

  • Download URL: privacify-0.2.0.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

Hashes for privacify-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e54bbe681eba7612948a1ed994bb56fd24dd2b8e252684e94685b2b6eba797c0
MD5 b67435459f02eb428f6f7ea083721e0a
BLAKE2b-256 c74dadfa482249ef117d92dbef8934d04a7d70cbcd966657bc42eff9fa964652

See more details on using hashes here.

File details

Details for the file privacify-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: privacify-0.2.0-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

Hashes for privacify-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9d1b36b7aebf0465424185585728cb5b932e1f15f141281e7b1c48568619d75
MD5 42d5dbadff792566a9f7d1c9a8e778c4
BLAKE2b-256 e6196198c22d13b0ecdf1f9ba26ee55576cb8a4ee7164fdaa56f8b804bcfdd9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page