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.1.tar.gz (10.0 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.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eucompliance_redact-0.1.1.tar.gz
  • Upload date:
  • Size: 10.0 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.1.tar.gz
Algorithm Hash digest
SHA256 8c0bd83380bbddca0c689780a61bcd723b59a9ed571ac81ae6792bd353daee29
MD5 877a2155b06990a5b97b16737e9dd5fd
BLAKE2b-256 a5f7cd42f5bbc009ea5bdfa43488aecc2585253a3a78503c6e5ced3038b64e8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eucompliance_redact-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8070fc2a99ca62257ef47908863bc7e434c5a661c92e7a00db594a86de30f880
MD5 9c4357de951a6d9660d4d7ae608b49b0
BLAKE2b-256 6192b8c5bc85c4575b089ea67a842888657c6b639630188c7cabfdfcac2682b0

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