secretstuff
pii detection and redaction. 150+ entity types. reversible.
// overview
secretstuff identifies, redacts, and reverses personally identifiable information in text using gliner models. it detects 150+ types of pii, replaces them with configurable dummy values, and stores mappings so you can restore originals when needed.
- detection — 150+ pii entity types via gliner nlp models
- redaction — replaces pii with configurable dummy values
- reversal — restores original pii from stored mappings
- production-ready — type hints, comprehensive testing, robust error handling
// installation
pip install secretstuff
// quick start
from secretstuff import SecretStuff
ss = SecretStuff()
text = "Contact John Smith at john@example.com or 555-123-4567"
# detect pii
entities = ss.detect(text)
for entity in entities:
print(f"{entity.type}: {entity.text}")
# redact pii
redacted = ss.redact(text)
print(redacted.text)
# "Contact [PERSON] at [EMAIL] or [PHONE]"
# reverse redaction
original = ss.reverse(redacted)
print(original)
# "Contact John Smith at john@example.com or 555-123-4567"
// api reference
SecretStuff()
main class. initializes the gliner model for entity detection.
detect(text: str) -> list[Entity]
identifies all pii entities in the text.
entity.type str — entity type (e.g. "email", "phone")
entity.text str — the matched text
entity.start int — start position in text
entity.end int — end position in text
redact(text: str) -> RedactedResult
replaces all pii with dummy values. returns result with text and mapping.
reverse(redacted: RedactedResult) -> str
restores original text from the redacted result's stored mappings.
// entity types
150+ entity types including:
- email addresses
- phone numbers
- social security numbers
- credit card numbers
- person names
- physical addresses
- dates of birth
- passport numbers
- driver's license numbers
- bank account numbers
- ip addresses
- medical record numbers
powered by gliner's zero-shot ner capabilities — no training required for new entity types.