A lightweight, zero-dependency output sanitizer for secrets, API keys, and PII.
Project description
redacted
Stop leaking secrets. One function call.
A lightweight, zero-dependency Python library that sanitizes secrets, API keys, PII, and sensitive data from text. Designed for LLM output pipelines.
Installation
pip install redacted
Quick Start
from main import sanitize_output
text = "My API key is sk-12345678901234567890"
clean = sanitize_output(text)
print(clean)
# Output: My API key is [OPENAI_KEY]
Features
- 20 Built-in Detectors: OpenAI, AWS, GitHub, Stripe, JWT, GCP, Slack, Twilio, Azure, Discord, PEM, Email, Phone, IPv4, SSN, Credit Cards, Env Vars, Local Paths, Connection Strings, Bearer Tokens.
- Zero Dependencies: Pure Python stdlib.
- Reversible Redaction: Keep a mapping of original secrets to restore them later.
- Streaming Support: Sanitize LLM streams token-by-token.
- Extensible: Add custom regex detectors easily.
Advanced Usage
Reversible Redaction
from main import sanitize_output, restore_output
result = sanitize_output("Email admin@test.com", detailed=True)
print(result.cleaned) # Email [EMAIL_1]
restored = restore_output(result.cleaned, result.mapping)
print(restored) # Email admin@test.com
Streaming
from main import StreamingSanitizer
sanitizer = StreamingSanitizer()
# feed tokens one by one
safe_token = sanitizer.feed("sk-")
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
llm_redacted-0.2.0.tar.gz
(10.1 kB
view details)
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 llm_redacted-0.2.0.tar.gz.
File metadata
- Download URL: llm_redacted-0.2.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8242c11626490d00236319aa06184c478030b199dc431ee671fc1a19b23c880
|
|
| MD5 |
f82af0947f5dfd0230313284169506f8
|
|
| BLAKE2b-256 |
863d00c2293aa07284de245f49a34ba9b6539f651644e56062ef064fdbea5dad
|
File details
Details for the file llm_redacted-0.2.0-py3-none-any.whl.
File metadata
- Download URL: llm_redacted-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a35ac637ea7950110a61543126558413560b6c7a62381dde975674a245b76128
|
|
| MD5 |
df57f851868c5ee26567f5276216a0fa
|
|
| BLAKE2b-256 |
aa51f969c081a4426d543d60daff1adcf879c8c3bdb381a52bc2bb9b09adcd4a
|