All Articles

How k-Anonymity Protects Your Passwords: Inside SHA-1 Prefix Breach Checking Without Leaks

How k-Anonymity Protects Your Passwords: Inside SHA-1 Prefix Breach Checking Without Leaks
Photo: Sendly Team / Unsplash

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.

Key Takeaways

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:

  1. Local Hashing: Your browser computes the SHA-1 digest of the password strictly in local memory. Never transmit the plaintext password over the network.
  2. 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.
  3. Bucket Retrieval: Send only the 5-character prefix over HTTPS (for example, GET https://api.pwnedpasswords.com/range/21BD1).
  4. 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.

Privacy-First Browser Suite

Try Sendly tools with zero sign-up

Transfer files peer-to-peer, sync collaborative notes live, or share your screen straight from any browser tab.

Open P2P TransferLive NotepadScreen Share

Continue Reading

Browse all articles
Browser-Side File Encryption Explained: AES-256-CBC, EvpKDF Key Derivation, and What Remains Unencrypted
Cryptography6 min read

Browser-Side File Encryption Explained: AES-256-CBC, EvpKDF Key Derivation, and What Remains Unencrypted

Measuring Password Strength Properly: Shannon Entropy, CSPRNG vs. Math.random(), and 6-Word Diceware
Cryptography6 min read

Measuring Password Strength Properly: Shannon Entropy, CSPRNG vs. Math.random(), and 6-Word Diceware

PREVIOUS ARTICLEPREVIOUS
SSRF Attacks and URL Sandboxing: How Modern Web Extractors Safely Fetch Untrusted Links

Every time an application accepts a user-supplied URL—whether to render a link preview, fetch Markdown for an AI agent, or inspect redirects—it opens a potentia...

NEXT ARTICLENEXT
URL Tracking Parameters Explained: How UTM, fbclid, and Redirect Chains Track You Across the Web

Every time you copy a link from a social media feed, marketing email, or sponsored search result, an invisible tail of query parameters—such as ?fbclid= , ?gcli...