Open Source · MIT License · v0.1.0

Your LLM never needs
to see real PII.

Privacy-first tokenization middleware for LLM pipelines. Strip sensitive data before it reaches any API. Restore originals on the way back. Local detection, encrypted vault, zero cloud dependency.

View on GitHub Quick Start →
your app ──► POST /v1/tokenize ──► llm-hasher ──► tokenized text │ detects PII locally (Ollama, no cloud) stores in encrypted vault (AES-256-GCM) your app ──► [LLM call with tokenized text] ← real PII never sent your app ──► POST /v1/detokenize ──► llm-hasher ──► original text restored
What it does

PII in. Tokens out. Originals back.

The LLM receives readable context — just not the actual sensitive values.

Before tokenization
Hi, my card is 4111-1111-1111-1111
and email is john@example.com
I live at 123 Main St, Boston
DOB: 14/03/1985
tokenize
→
detokenize
After tokenization
Hi, my card is CREDIT_CARD_j7_4f8a2b
and email is EMAIL_j7_9c3d1a
I live at HOME_ADDRESS_j7_2b1e9f
DOB: DATE_OF_BIRTH_j7_7a3c1d
Features

Built for production.

Everything you need to protect user data in LLM pipelines.

🔍

Hybrid detection

Regex for structured types (cards, IBANs, emails). Local Ollama for contextual types (names, addresses, national IDs). Best of both.

🏠

100% local

Detection runs on your own infra via Ollama. Raw data never leaves your network — not even for the detection step.

🔐

Encrypted vault

Token↔value mappings stored in AES-256-GCM encrypted SQLite. Keys never leave the process.

🆔

Your own IDs

Use context_id from your domain (contact_123, zoom_call_789) instead of tracking foreign UUIDs.

⚡

Parallel processing

Large texts chunked and processed in parallel goroutines. Single-pass Aho-Corasick detokenization.

📦

Dual-use

Run as a standalone HTTP service or import as a Go library. One Docker Compose command to start everything.

Coverage

10 PII types detected.

Structured and contextual — handled differently, protected equally.

CREDIT_CARD Regex Visa, MC, Amex, Discover
PERSON_NAME LLM Context-aware
EMAIL Regex All formats
HOME_ADDRESS LLM Context-aware
PHONE_NUMBER Regex International formats
NATIONAL_ID LLM SSN, TC Kimlik, NIN…
BANK_ACCOUNT Regex IBAN
PASSPORT LLM Context-aware
IP_ADDRESS Regex IPv4
DATE_OF_BIRTH LLM Context-aware
Integration

Drop-in for any stack.

HTTP service or Go library — use whatever fits your architecture.

Python
Go library
cURL
# 1. Tokenize before sending to LLM
resp = requests.post("http://localhost:8080/v1/tokenize", json={
    "text": transcript,
    "context_id": f"zoom_{call_id}"
})
tokenized = resp.json()

# 2. Send tokenized text to your LLM — real PII never transmitted
llm_response = openai.chat.completions.create(
    messages=[
        {"role": "system", "content": "Summarize this call transcript."},
        {"role": "user",   "content": tokenized["tokenized_text"]}
    ]
)

# 3. Detokenize the response
final = requests.post("http://localhost:8080/v1/detokenize", json={
    "text": llm_response.choices[0].message.content,
    "context_id": f"zoom_{call_id}"
})
print(final.json()["original_text"])
import "github.com/yemrealtanay/llm-hasher/pkg/hasher"

h, err := hasher.New(
    hasher.WithOllama("http://localhost:11434", "llama3.2:3b"),
    hasher.WithVault("data/vault.db", ""),
)
defer h.Close()

// Tokenize
result, err := h.Tokenize(ctx, transcript, "zoom_call_789", nil)
// result.Text → tokenized transcript, safe to send to any LLM

// Detokenize after LLM response
original, err := h.Detokenize(ctx, llmResponse, "zoom_call_789")
# Tokenize
curl -X POST http://localhost:8080/v1/tokenize \
  -H "Content-Type: application/json" \
  -d '{"text":"Hi, my card is 4111-1111-1111-1111","context_id":"session_1"}'

# Response
{
  "tokenized_text": "Hi, my card is CREDIT_CARD_sess1_4f8a2b",
  "context_id": "session_1",
  "entities": [
    { "token": "CREDIT_CARD_sess1_4f8a2b", "pii_type": "CREDIT_CARD" }
  ]
}

# Detokenize
curl -X POST http://localhost:8080/v1/detokenize \
  -H "Content-Type: application/json" \
  -d '{"text":"CREDIT_CARD_sess1_4f8a2b","context_id":"session_1"}'
Get started

Up in 60 seconds.

Docker Compose handles everything — Ollama, model download, service startup.

01 — Clone

Get the repo

git clone github.com/yemrealtanay/llm-hasher
02 — Start

One command

make docker-up

Pulls Ollama + llama3.2:3b (~2GB), starts on port 8080.

03 — Verify

Health check

curl localhost:8080/healthz

Returns {"status":"ok"}

Stop sending PII to LLMs.

Open source, MIT license. Self-hosted. No vendor lock-in.