Skip to main content

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 llm_redacted 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 llm_redacted 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 llm_redacted import StreamingSanitizer

sanitizer = StreamingSanitizer()
# feed tokens one by one
safe_token = sanitizer.feed("sk-")

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

llm_redacted-0.2.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

llm_redacted-0.2.1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file llm_redacted-0.2.1.tar.gz.

File metadata

  • Download URL: llm_redacted-0.2.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for llm_redacted-0.2.1.tar.gz
Algorithm Hash digest
SHA256 eeea7b6e27924cf36b1bf43ad94ee784018f4fe1bc6014ab30970e8dbb712d8f
MD5 36ea3c4dbc37b1312a86d1115cb75a92
BLAKE2b-256 be7c452ed28778abcf32fc13f76b8847cb4aabe4233e26fa0fe79a8c2a56bc49

See more details on using hashes here.

File details

Details for the file llm_redacted-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: llm_redacted-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for llm_redacted-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c5f0b1f5ee5166b6ab0074714651e645065d38f3f599f751853e814ec797a245
MD5 bcfe786b8be202a0db00626f95df9a32
BLAKE2b-256 be7d77a02a3df8a44e12419d9d0f909f4642269b5b7f1e5db32f477bef3d41ce

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