Skip to main content

Heuristic prompt masking utility for sensitive data

Project description

PromptMasker

PromptMasker is a prompt-sanitization utility that heuristically detects and masks sensitive data in raw text before it is sent to LLMs, logs, or external services.

It is designed to sit before your model call or logging layer and reduce the risk of accidentally leaking credentials or personal data.

This is redaction, not encryption.


Why PromptMasker exists

LLMs are often fed:

  • raw user input
  • debugging prompts
  • logs copied from real systems

Those inputs frequently contain:

  • API keys
  • emails
  • phone numbers
  • internal IDs

PromptMasker is built to intercept that text early and neutralize obvious sensitive tokens without requiring rigid schemas or strict formatting.


What it masks

PromptMasker attempts to detect and mask:

  • API keys / secrets
    Context-aware, alphanumeric tokens near phrases like “api key”

  • Email addresses
    Detected by structure and local intent

  • Phone / mobile numbers
    Numeric tokens (8–15 digits) near phone-related phrases

  • Generic sensitive tokens
    Long numeric or mixed alphanumeric identifiers via fallback heuristics


How detection works (important)

Detection is heuristic and layered, not rule-perfect:

  • Fuzzy keyword matching
    (api key, email id, phone no, etc.)

  • Sliding context windows
    (tokens near intent phrases are prioritized)

  • Structural heuristics
    (length, digits, alphanumeric composition)

  • Global fallback
    for obviously sensitive-looking tokens

This means:

  • false positives are possible
  • behavior is intentionally conservative

That trade-off is deliberate.


What PromptMasker is NOT

  • Not encryption
  • Not anonymization
  • Not compliance-grade security

If you need cryptographic guarantees, do not use this.


Installation

pip install promptmasker

Sample Usage

from promptmasker import PromptMasker

masker = PromptMasker(mode="hash", salt="session")
text = "My api key is sk-1234567890 and email test@example.com"

print(masker.mask(text))

Project details


Release history Release notifications | RSS feed

This version

0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptmasker-0.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

promptmasker-0.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file promptmasker-0.0.tar.gz.

File metadata

  • Download URL: promptmasker-0.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for promptmasker-0.0.tar.gz
Algorithm Hash digest
SHA256 e54ebae083e2d1e8123d453a44ea60ee8560a625f77aa8324af8e2b7c0f8101b
MD5 f4b3150b4f4aac54145c70428ae1a0d3
BLAKE2b-256 111197a7f38dc419ab6f11353acee98b0f143842854dd62004ee5a1aa3d653a6

See more details on using hashes here.

File details

Details for the file promptmasker-0.0-py3-none-any.whl.

File metadata

  • Download URL: promptmasker-0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for promptmasker-0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f61b108876e85e96d27150fe8652e096ea5e0b1bcab7292bd1116c1ef8167ba
MD5 92cfa515a01645d2c85c0b079348d78b
BLAKE2b-256 af3b45edd982b37853a8501bdf6ffe469b9daa6c2bdaa716cbd51eb13ae8389b

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