Skip to main content

Rust-backed Python library for detecting and redacting common PII in text

Project description

Redactix

Redactix logo

Redactix is a lightweight Rust-backed Python library for detecting and redacting common PII in text.

Redactix is currently an alpha release. The detector set is intentionally small, and public APIs may change before a stable 1.0 release.

  • Rust-backed speed for high-throughput text redaction.
  • Simple Python API for detection, redaction, and reporting.
  • Lightweight design focused on common structured PII and custom regex detectors.

Default Detectors

Name Detection method Validator
email Regex NULL
phone Regex Boundary checks; 10-15 digits; rejects repeated single-digit numbers
credit_card Regex Luhn checksum; 13-19 digits

Comparison

Redactix is focused on lightweight, deterministic text redaction for common structured PII. It is intentionally smaller than full PII detection frameworks.

Library Difference
Redactix Lightweight Rust-backed Python library with a simple API, built-in regex/validator detectors, custom regex detectors, and deterministic overlap resolution.
Microsoft Presidio Much broader framework: NLP, regex, checksums, context-aware recognizers, multilingual support, text/images/structured data, Docker/PySpark/K8s options. More powerful but heavier. Source: Presidio README.
scrubadub Python free-text scrubber with more built-in PII types: names, addresses, DOBs, URLs, credentials, SSNs, tax IDs, etc., plus optional/external detectors. Source: scrubadub docs.

Installation

Install from PyPI:

pip install pyredactix

Import the package as:

import redactix

For local development builds:

uv run maturin develop

Quick Start

import redactix

redactor = redactix.Redactor(
    detectors=["email", "credit_card"],
    mask_strategy="placeholder",
)

redactor.register_detector(
    name="employee_id",
    pattern=r"\bEMP\d{6}\b",
    placeholder="{{EMPLOYEE_ID}}",
    enabled=True,
)

cleaned = redactor.redact(text)
detections = redactor.detect(text)
report = redactor.redact_with_report(text)

redact() returns only redacted text:

redactix.redact("Email alex@example.com")
# "Email {{EMAIL}}"

detect() returns structured Detection dataclasses:

[
    redactix.Detection(
        start=6,
        end=22,
        value="alex@example.com",
        entity_type="EMAIL",
        detector_name="email",
        replacement="{{EMAIL}}",
    )
]

redact_with_report() returns a RedactionResult dataclass with both the cleaned text and detections used for redaction.

Redactor API

redactix.Redactor(
    detectors: Optional[Sequence[str]] = None,
    mask_strategy: "placeholder" | "fixed" | "length_preserving" = "placeholder",
    placeholder_format: str = "{{{entity_type}}}",
    mask_char: str = "*",
    fixed_mask: str = "***",
)

detectors=None enables all built-in detectors. Pass a subset such as ["email"] to enable only those detectors, or [] to start with no built-ins and register only custom detectors.

Masking Strategies

  • placeholder replaces matches with stable placeholders such as {{EMAIL}}.
  • fixed replaces every match with fixed_mask, which defaults to ***.
  • length_preserving replaces each Python character in the match with mask_char.

Examples:

redactix.redact("Email alex@example.com", mask_strategy="fixed")
# "Email ***"

redactix.redact("Email alex@example.com", mask_strategy="length_preserving")
# "Email ****************"

Custom Detectors

Register custom regex-based detectors on a Redactor:

redactor = redactix.Redactor(detectors=[])
redactor.register_detector(
    name="employee_id",
    pattern=r"\bEMP\d{6}\b",
    placeholder="{{EMPLOYEE_ID}}",
    enabled=True,
    priority=100,
)

Detector names are normalized to lowercase identifiers for detector_name; placeholders and entity types use uppercase forms such as EMPLOYEE_ID.

Overlapping matches are resolved deterministically:

  • Higher priority wins.
  • If priority is equal, the longer match wins.
  • Remaining ties are resolved by source position and registration order.

Roadmap

  • Add more common PII detectors and localized PII patterns.
  • Add optional AI-powered NER detection for advanced use cases while keeping the core library lightweight.

Contributing

Development setup, test commands, and contribution guidance are documented in CONTRIBUTING.md.

License

Redactix is distributed 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

pyredactix-0.1.0.tar.gz (830.5 kB view details)

Uploaded Source

Built Distributions

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

pyredactix-0.1.0-cp39-abi3-win_amd64.whl (768.5 kB view details)

Uploaded CPython 3.9+Windows x86-64

pyredactix-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

pyredactix-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (989.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

pyredactix-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (863.4 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pyredactix-0.1.0.tar.gz
  • Upload date:
  • Size: 830.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyredactix-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4994626e70103bd0867a4e748d189da0d96524442a6bf2eac99607f365599589
MD5 cf1277b8d9f967e670150ceea80ad53c
BLAKE2b-256 42ba7b72830d40cfe11621bda6fb7803d81417b19d5f6ae08a49be15e30bf393

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyredactix-0.1.0.tar.gz:

Publisher: release.yml on RikidWai/Redactix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyredactix-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: pyredactix-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 768.5 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyredactix-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 06d9320eee14981b8a2e95be2f4f876a78b151e4d665153c0fce91b362245992
MD5 7c285e61cea96d130f80daa7dfbc69e3
BLAKE2b-256 2f3c24d6b6b0c0d337cb771c2d4cce6792c809c6eb37d28688ffec75944fa83a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyredactix-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: release.yml on RikidWai/Redactix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyredactix-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyredactix-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e217d05cd367d92b4a087c60ce2d219d5bc7d900b16cfd26a89969641ed8df30
MD5 745449681ac3facc6dafbf1377c61a77
BLAKE2b-256 cc6b3c3f66f4041f181b9118ecf498b59ca3f8a1d62be525207322d621cfe63f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyredactix-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on RikidWai/Redactix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyredactix-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyredactix-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c6ab7405d5608bcd1dcdf2a5a19dc6c698ea95a226ff6f6d36c8945b3283e5ef
MD5 216dad7f33e25479e9f074ad4e254e0e
BLAKE2b-256 682c45dc18bd35aaf91615e6ced8648ded09f26865d055967ec154c670bd818a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyredactix-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on RikidWai/Redactix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyredactix-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyredactix-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3a68cf9b75cdc93e500e45cf43779cbc79847acc21f32a1a03a042b8167aed3a
MD5 05e7b0ae0586e6d57c8a80f5d5a3b9dc
BLAKE2b-256 0e01e5ad6365d8491374947417b5ca5afb7bd906df45fa78064b921f5e7d6606

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyredactix-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on RikidWai/Redactix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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