Skip to main content

Strip personal data and credentials from prompts before they reach a model - locally, with a signed record that you did

Project description

eucompliance-redact

Strip personal data and credentials from prompts before they reach a model — locally, with a signed record that you did.

Every prompt you send to a hosted model is a transfer to a processor. If it contains a customer address, an IBAN or an API key, that is a disclosure under GDPR Art. 28 — and, for providers outside the EU, Art. 44. The obligation is not politeness, it is liability.

pip install eucompliance-redact
from eucompliance_redact import redact

clean = redact(prompt)
answer = model(clean.text)        # only placeholders left
print(clean.restore(answer))      # placeholders put back

No dependencies. No network calls. Nothing to configure.

Or wrap the client once

from eucompliance_redact import wrap
from openai import OpenAI

client = wrap(OpenAI())
client.chat.completions.create(model="gpt-4o", messages=[...])

Prompts are redacted on the way out and the answer is translated back on the way in, so your users never see a placeholder. If anything in this library fails, the call goes through unchanged — a safeguard that stops production gets switched off.

What it finds

Private keys · AWS keys · GitHub tokens · OpenAI and Anthropic keys · Slack tokens · JWTs · credentials embedded in URLs · IBANs (checksum-verified) · payment cards (Luhn-verified) · e-mail addresses · VAT IDs · IP addresses.

Phone numbers are off by default: almost any long digit sequence looks like one, and invoice numbers are the usual casualty. Enable with include_unsafe=True.

redact(text, skip=["IPV4"])            # leave internal addresses alone
redact(text, kinds=["IBAN", "EMAIL"])  # only these

What it does not find — read this part

This is pattern matching. It finds what has structure: a checksum, a prefix, a shape. It does not find a person's name sitting in ordinary prose, a street address written out in words, or a medical detail described in a sentence. No amount of regular expressions will, and a library that claims otherwise is more dangerous than no library at all, because you would stop looking.

Use it to remove the leaks that are mechanical and constant. Do not use it as your only control over what goes into a prompt.

Placeholders are stable

The same value becomes the same placeholder everywhere in the text, so the model can still tell that two mentions are the same person:

r = redact("a@x.at wrote to b@y.at, then a@x.at again")
r.text
# '[EMAIL_1] wrote to [EMAIL_2], then [EMAIL_1] again'
r.count      # 3 occurrences
len(r.mapping)  # 2 distinct values

Proving you did it

Redaction that nobody can verify is worth little in an audit. receipt() returns a signed record of that redaction happened — how many values of which kinds, and the hashes before and after:

from eucompliance_redact import receipt, redaction_summary

r = redact(prompt)
record = receipt(r, controller="Your Company GmbH", processor="OpenAI")
summary = redaction_summary(record)

Only the two hashes and the per-kind counts are transmitted. Not one redacted value, not one line of the prompt. The record is signed with EIP-191 and verifiable by anyone, free and without an account — at eucompliance.tools/verify.

This is the only part that touches the network, and it is optional. Without it, the package is fully offline.

What the record proves

Proves: that a text with this hash was reduced to a text with that hash, removing this many values of these kinds, at this time, attested by this controller.

Does not prove: that nothing sensitive remained. See the section above. It is evidence of a control being applied, not a guarantee of the result.

Not legal advice. Whether your processing is lawful remains your assessment.

Related

MIT licensed. Operated by Patrick Kaufmann, sole proprietor in Vienna, Austria.

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

eucompliance_redact-0.1.2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

eucompliance_redact-0.1.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file eucompliance_redact-0.1.2.tar.gz.

File metadata

  • Download URL: eucompliance_redact-0.1.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for eucompliance_redact-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ffb54aea7e8fc72700e38559acd1f5e8080fb9a0742e0520f58bd66f758578ac
MD5 04687f3ca33c98dc2e6822690c2ff85a
BLAKE2b-256 b0d21d2be130609044407301f99afb6abab7145844057f5c4fce26eec02b8436

See more details on using hashes here.

File details

Details for the file eucompliance_redact-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for eucompliance_redact-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8898c33a7025355cb192fe090152919f572e7ac2b7fa2e60476e7e10e1133a96
MD5 0503d6f555d25f4551278feeb8c80ad0
BLAKE2b-256 e14cb1c6f63298f61b2c6c41e3706810040f1674984dc50a213006d9518a8150

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