Skip to main content

Framework for masking and unmasking PII.

Project description

🕶️ VeilData

A lightweight framework for masking and unmasking Personally Identifiable Information (PII).

CI PyPI version License


🧠 Why VeilData

Modern AI systems touch sensitive data every day.
VeilData makes it easy to redact, anonymize, and later restore information—using the same composable design you love from PyTorch.


🚀 Quick Start

Installation

From PyPI

pip install veildata

Run from Docker

docker build -t veildata .
alias veildata="docker run --rm -v \$(pwd):/app veildata"
veildata mask data/input.csv --out data/redacted.csv

Running in Docker

docker build -t veildata .
docker run -it ghcr.io/veildata/veildata:latest

For Development

git clone https://github.com/VeilData/veildata.git
cd veildata
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv sync

Quickstart Guide

Mark sensitive data

veildata mask input.txt --out masked.txt

Reveal previously mask data

veildata unmask masked.txt --store mappings.json --out revealed.txt

** Using Docker**

docker run --rm -v $(pwd):/app veildata mask input.txt --out masked.txt

Examples

Regex-based Masking

from veildata import Compose, RegexMasker, TokenStore

# Create a shared TokenStore for reversible masking
store = TokenStore()

# Define your masking pipeline with the shared store
masker = Compose([
    RegexMasker(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}", store=store),  # email
    RegexMasker(r"\b\d{3}-\d{3}-\d{4}\b", store=store),                           # phone
])

text = "Contact John at john.doe@example.com or call 123-456-7890."

# --- Mask the data ---
masked_text = masker(text)
print(masked_text)
# -> Contact John at [REDACTED_1] or call [REDACTED_2].

# --- Unmask it later ---
unmasked_text = store.unmask(masked_text)
print(unmasked_text)
# -> Contact John at john.doe@example.com or call 123-456-7890.

spaCy Named Entity Recognition

# Requires `pip install veildata[spacy]`
from veildata.maskers.ner_spacy import SpacyNERMasker
from veildata import TokenStore

# Shared token store for reversible unmasking
store = TokenStore()

masker = SpacyNERMasker(
    entities=["PERSON", "ORG"],
    store=store
)

text = "John works at OpenAI in San Francisco."

# --- Mask automatically and track mappings ---
masked = masker(text)
print(masked)
# -> [REDACTED_1] works at [REDACTED_2] in San Francisco.

# --- Unmask using the same store ---
unmasked = store.unmask(masked)
print(unmasked)
# -> John works at OpenAI in San Francisco.

BERT-based Masking

from veildata.bert_masker import BERTNERMasker

masker = BERTNERMasker(model_name="dslim/bert-base-NER")
text = "Email Jane at jane.doe@example.com"
print(masker(text))
# -> Email [REDACTED] at [REDACTED]

🛠️ Continuous Integration

  • CI: .github/workflows/ci.yml runs linting, formatting, build, and tests on every push or PR.
  • Publish: .github/workflows/publish.yml auto-publishes to PyPI when a new v* tag or release is created.

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

veildata-0.1.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

veildata-0.1.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file veildata-0.1.0.tar.gz.

File metadata

  • Download URL: veildata-0.1.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for veildata-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ca6fec54461af0d94ff14b39ba02587d6e1741a18edb8e2a0dc2d803e7e0ee3b
MD5 ccd76d98be1cfc21f2a451816370a631
BLAKE2b-256 a2ba84ae35bf5828a1d10421af2cfddf84518d7069c004d3efe186dfb9fb418f

See more details on using hashes here.

File details

Details for the file veildata-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: veildata-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for veildata-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02d57ce4099f408e6ea4ca571e606320a05d54cafc588b332b329f61ab4834b2
MD5 b0f039d6bf48ab3ee42cb34b3630aa7e
BLAKE2b-256 b99ebe6ed3eb2b3bb1f9be29ddf8c6f315efa8d1c317cebadb0e7cb25a140343

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