<- cd ~/andacbasaran.com
$cat ~/notes/offline-pii-secret-detection-rust-python.md 4 min read
2026-12-02 · Developer Note

Sub-Millisecond Offline PII & Secret Detection in Rust and Python

Combining rayon parallelism, checksum-verified validators (Luhn, IBAN, TCKN, VKN), and reversible LLM proxying without cloud APIs.

Regex-only secret and PII scanners drown developers in false positives — flagging random 11-digit IDs, test hashes, or UUID fragments. While building LeakGuard (Rust) and CloakVault (Python), the goal was deterministic, 100% offline detection fast enough for Git pre-commit hooks and live LLM proxies.

1. Checksum-Verified PII Eliminates Noise

Before raising an alert, candidate matches pass mathematical validation: Luhn for payment cards, Mod-97 for IBANs, and official checksum algorithms for Turkish TCKN and VKN numbers. High-entropy API keys are cross-checked with Shannon entropy thresholds and known provider prefixes.

2. Parallel Scanning & SARIF 2.1.0 Output

LeakGuard walks repositories in parallel with Rust's rayon crate, respecting .gitignore rules and emitting terminal reports, JSON, or GitHub-compatible SARIF 2.1.0 directly inside CI pipelines and pre-commit hooks.

3. Reversible Redaction for Live LLM Prompts

CloakVault sits locally as an OpenAI-compatible proxy (0.16 ms P50), swapping sensitive values for deterministic placeholders before prompts leave the machine and restoring them on the way back — with every event logged to an embedded SQLite WAL+FTS5 audit database.