A Python library for redacting PII from text using privacy-filter model
Project description
pii-safe — Redact PII from text
Install
pip install pii-safe
Usage
from pii_safe import redact_text
text = "mi nombre es Dario Clavijo"
redacted = redact_text(text)
print(redacted) # mi nombre es[REDACTED_10eda051]
Using the Redacter class
from pii_safe import Redacter
redacter = Redacter()
result1 = redacter.redact("mi nombre es Dario Clavijo")
result2 = redacter.redact("el es Dario Clavijo")
# Same PII gets consistent hash
hash_map = redacter.get_hash_map()
print(hash_map) # {'Dario Clavijo': '10eda051'}
CLI
pii-safe input.txt
pii-safe input.txt -o output.txt
Development
git clone https://github.com/daedalus/pii-safe.git
cd pii-safe
pip install -e ".[test]"
# run tests
pytest
# format
ruff format src/ tests/
# lint
ruff check src/ tests/
# type check
mypy src/
API
redact_text(text: str) -> str
Redacts PII from text using the openai/privacy-filter model.
class Redacter
Context manager for consistent PII-to-hash mapping across calls.
redact(text: str) -> str: Redact PII from textget_hash_map() -> dict[str, str]: Get PII-to-hash mapping
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pii_safe-0.1.0.tar.gz.
File metadata
- Download URL: pii_safe-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e40a0c78ff22bfffd8c8d5c7d6931f7ff031b5c1ce3cee618937e895d0ace2a
|
|
| MD5 |
b84da7cab54c6c33d2c1dbd95909e93e
|
|
| BLAKE2b-256 |
4edca259348297439ae32dab9beb24687db512e9567981bf70e4ca5939e4e550
|
Provenance
The following attestation bundles were made for pii_safe-0.1.0.tar.gz:
Publisher:
pypi-publish.yml on daedalus/pii-safe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pii_safe-0.1.0.tar.gz -
Subject digest:
7e40a0c78ff22bfffd8c8d5c7d6931f7ff031b5c1ce3cee618937e895d0ace2a - Sigstore transparency entry: 1364268133
- Sigstore integration time:
-
Permalink:
daedalus/pii-safe@49fac1e3b49dbd4736cfd6942a5326d3df3e2e9e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/daedalus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@49fac1e3b49dbd4736cfd6942a5326d3df3e2e9e -
Trigger Event:
release
-
Statement type:
File details
Details for the file pii_safe-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pii_safe-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f71bf303724e8f9d984a0b45f92448fdeafe85cb72df0201b9f618cedb45696c
|
|
| MD5 |
99d83a0ba0e4edd2132bb307c25019ec
|
|
| BLAKE2b-256 |
644056180d1f7728782d8e720d9fb5a53e56a4cb42d2707fb9de47d25896faa4
|
Provenance
The following attestation bundles were made for pii_safe-0.1.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on daedalus/pii-safe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pii_safe-0.1.0-py3-none-any.whl -
Subject digest:
f71bf303724e8f9d984a0b45f92448fdeafe85cb72df0201b9f618cedb45696c - Sigstore transparency entry: 1364268195
- Sigstore integration time:
-
Permalink:
daedalus/pii-safe@49fac1e3b49dbd4736cfd6942a5326d3df3e2e9e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/daedalus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@49fac1e3b49dbd4736cfd6942a5326d3df3e2e9e -
Trigger Event:
release
-
Statement type: