Checking whether your password has appeared in a public data breach creates an obvious paradox: how can you ask an external breach database if your secret is compromised without actually revealing your password—or even its unique hash—over the internet? The answer lies in cryptographic k-anonymity.
TL;DR: Under the Have I Been Pwned k-anonymity model, your browser hashes a password locally using SHA-1 and sends only the first 5 hexadecimal characters. The API returns hundreds of matching suffixes, and your device compares the full hash privately in memory.
1. Why Sending Even a Full Hash Is Unsafe
A common anti-pattern in naive password checkers is hashing a user's password on the client and sending the entire 40-character SHA-1 digest to a server. Even though SHA-1 is a one-way function, sending the full hash leaks a deterministic fingerprint: anyone observing server logs can correlate the exact digest against precomputed rainbow tables or link multiple queries from the same user.
2. How 5-Character Prefix Splitting Creates Privacy by Math
Introduced across modern password managers and popularized by Troy Hunt's Have I Been Pwned Pwned Passwords API, k-anonymity ensures any individual query blends into a large crowd of k indistinguishable candidates:
- Local Hashing: Your browser computes the SHA-1 digest of the password strictly in local memory. Never transmit the plaintext password over the network.
- Prefix Truncation: Split the 40-character hex digest into a 5-character prefix (20 bits, representing 165 = 1,048,576 buckets) and a 35-character suffix.
- Bucket Retrieval: Send only the 5-character prefix over HTTPS (for example,
GET https://api.pwnedpasswords.com/range/21BD1). - Local Matching: The API returns roughly 400 to 900 hash suffixes sharing that 5-character prefix along with their breach counts. Your browser searches that list locally for the remaining 35-character suffix.
// Example flow inside browser memory:
Plaintext Input ➔ "example-secret" (NEVER leaves device)
Local SHA-1 Hash ➔ 21BD1...8C94F3A7 (Computed in browser)
Network Request ➔ GET /range/21BD1 (Only first 5 hex chars sent!)
Local Comparison ➔ Match remaining 35 chars against returned bucket
3. Quantifying Entropy vs. Keyboard Walks
Checking breach databases is only half the story—newly invented passwords never seen in a leak can still fail in milliseconds if they follow predictable human patterns. Attackers use rule-based crackers that combine dictionary roots, year suffixes, leetspeak substitutions (@ for a, 0 for o), and keyboard walks (qazwsx, 1q2w3e4r).
| Credential Style | Estimated Search Space | Offline GPU Resistance |
|---|---|---|
8-Char Mixed + Pattern (P@ssw0rd) |
< 25 effective bits (dictionary rules) | Seconds to minutes |
| 4-Word Random Diceware | ~51+ bits (7,7764 combinations) | Years to centuries (depending on KDF) |
| 16-Char Cryptographic Random | ~95+ bits | Computationally infeasible |
4. Auditing Passwords Safely Without Risk
Always verify password strength inside a client-side engine that measures character entropy, flags dictionary roots and keyboard walks locally, and keeps optional k-anonymity lookups opt-in. You can test passphrase strength and generate high-entropy Diceware keys locally right now using Sendly's Password Strength Auditor.


