Skip to main content

A sensitive data handler python library

Project description

Build Status

ShadowData

A Python library for anonymizing, masking, and encrypting sensitive data with a small, focused API.

What it does today

  • Text and pattern anonymization (free-form text replacement, IPv4, email, phone)
  • Localized identifiers (US SSN, Brazil CPF/CNPJ)
  • Symmetric encryption and decryption (Fernet)
  • PII detection via spaCy (optional extra)

Planned: richer masking helpers and reversible transforms.

Installation

pip install shadow_data

Optional spaCy support:

pip install shadow_data[spacy]

spaCy models must be installed before use:

python -m spacy download en_core_web_trf

Quickstart

from shadow_data.anonymization import (
    EmailAnonymization,
    Ipv4Anonymization,
    PhoneNumberAnonymization,
    TextProcessor,
)
from shadow_data.cryptohash.symmetric_cipher import Symmetric
from shadow_data.l10n.usa import IdentifierAnonymizer

text = "Contact me at user@example.com or 415-555-0199. Server: 10.0.0.1"
anonymized_text = Ipv4Anonymization.anonymize_ipv4(text)
anonymized_text = TextProcessor.replace_text("Contact", "Reach", anonymized_text)
email = EmailAnonymization.anonymize_email("user@example.com")
phone = PhoneNumberAnonymization.anonymize_phone_number("415-555-0199")
print(anonymized_text, email, phone)

ssn = "Billy's SSN is 479-92-5042."
ssn_anonymizer = IdentifierAnonymizer(ssn)
ssn_anonymizer.anonymize()
print(ssn_anonymizer.cleaned_content)

symmetric = Symmetric()
key = symmetric.create_key()
ciphertext = symmetric.encrypt("hello")
plaintext = symmetric.decrypt(ciphertext)
print(ciphertext, plaintext)

Docs

  • docs/README.md
  • docs/usage.md
  • docs/cryptography.md
  • docs/pii.md

Examples

  • examples/quickstart.py
  • examples/anonymization.md
  • examples/i10n_us.md
  • examples/i10n_brazil.md
  • examples/pii_nlp.md
  • examples/symmetric_cipher.md

Testing

poetry run pytest -vvv

Contributing

  1. Fork the repository.
  2. Create a new branch for your feature (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push the branch (git push origin my-new-feature).
  5. Open a pull request.

License

This project is licensed under the MIT License - see LICENSE for details.

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

shadow_data-1.0.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

shadow_data-1.0.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file shadow_data-1.0.1.tar.gz.

File metadata

  • Download URL: shadow_data-1.0.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.13 Linux/6.6.114.1-microsoft-standard-WSL2

File hashes

Hashes for shadow_data-1.0.1.tar.gz
Algorithm Hash digest
SHA256 81fdaad114282482a6a8ff0d8779ec399cfc35399c52ad09bd047a65e6db432b
MD5 e9e6c6c661a61f07ae4b68fd8a839c7d
BLAKE2b-256 c3f3b21702300e02282068353b305dcf918e348cff188d226d20a246ff8cae53

See more details on using hashes here.

File details

Details for the file shadow_data-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: shadow_data-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.13 Linux/6.6.114.1-microsoft-standard-WSL2

File hashes

Hashes for shadow_data-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c392705c2944bdd6fbfb6c0082c7bb552b12265561ae7691214ec607b519f1f
MD5 b0afc78465b2f6355749b0bdf5fd44e7
BLAKE2b-256 40af0a21c979ef8afc41207e0a53ee8ab6de392098f1d8531e8c212bdcaa209c

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