Sitelet https://github.com/spacexnu/ShadowData
Skip to content

Repository files navigation

Build Status

ShadowData

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

📖 Documentation

Features

  • Anonymization — free-form text, IPv4 addresses, emails, phone numbers
  • Localized identifiers — US SSN, Brazil CPF/CNPJ
  • Masking — credit cards with Luhn validation, formatted identifiers, partial emails
  • Pseudonymization — reversible tokens, plus deterministic tokens for joins
  • Encryption — symmetric encryption and decryption via Fernet
  • PII detection — named entity recognition with spaCy (optional extra)

Installation

Requires Python 3.10 or newer.

pip install shadow_data

With PII detection:

pip install "shadow_data[spacy]"
python -m spacy download en_core_web_sm

Quickstart

from shadow_data import (
    EmailAnonymization,
    Pseudonymizer,
    UsaIdentifierAnonymizer,
    mask_credit_card,
)

EmailAnonymization.anonymize_email('user@example.com')  # '****@****ple.com'
UsaIdentifierAnonymizer('SSN: 479-92-5042').anonymize()  # 'SSN: XXX-XX-5042'
mask_credit_card('4111 1111 1111 1111')  # '**** **** **** 1111'

pseudonymizer = Pseudonymizer()
token = pseudonymizer.pseudonymize('user@example.com')
pseudonymizer.depseudonymize(token)  # 'user@example.com'

See Getting started for a full tour, and Choosing a technique if you are unsure which helper fits your case.

Development

poetry install --with dev,docs --extras spacy
make all   # ruff, mypy, docs build, and pytest with coverage

See Contributing.

Changelog

See CHANGELOG.md.

License

MIT — see LICENSE.

About

A sensitive data handler python library

Topics

Resources

Contributing

Stars

5 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages