K-Anonymity Password Check: How Lookup Stays Private

K-anonymity password check explained: only 5 SHA-1 characters leave your browser. How the HIBP range API works, why SHA-1 is just a lookup key, and what the…

When a password checker says it uses "k-anonymity" to look your password up in breach data, it is making a precise claim: the service running the lookup cannot learn which password you checked. This page explains exactly how a k-anonymity password check works, what leaves your browser, and — just as important — what the model does not hide.

What k-anonymity means

The term comes from Latanya Sweeney’s work on anonymizing datasets: a dataset is k-anonymous when every record in it is indistinguishable from at least k−1 other records. Translated to password lookups: whatever you send to the server must match at least k different passwords, so the server cannot single yours out.

In the model used by Have I Been Pwned’s Pwned Passwords API — the engine behind most "check if your password leaked" tools, including our breach checker — k is large: one 5-character prefix typically matches many hundreds of hash entries.

How a k-anonymity password check works, step by step

  1. Your browser hashes the password with SHA-1 and uppercases the hex digest. The password itself never leaves the page.
  2. Only the first 5 hex characters of the digest (the "prefix") are sent, to https://api.pwnedpasswords.com/range/<prefix>.
  3. The API replies with every known breached hash sharing that prefix — usually several hundred lines of suffix:count, where the count is how many breaches contain that password.
  4. Your browser searches that list locally for the remaining 35 characters of your digest. A match means the password is in the breach corpus; the count shows how often it appears.
# The whole protocol with curl (prefix ABCDE is an example)
curl https://api.pwnedpasswords.com/range/ABCDE

# Reply, one line per hash that shares the prefix:
0018A45C4F16FB1971A8AD4F1B3E7C3A5B2:3
00D4F6E8FA6EECAD2A3AA415EEC418D38EC:2
...
# note what is absent: the full 40-character digest never appears
# in the reply — only the 35-character tail after your prefix

That is the entire exchange. One request, no account, no password in transit. You can watch it happen in the browser dev tools network tab while a check runs.

Why SHA-1

SHA-1 here is a lookup key, not a security boundary. The corpus is a giant index of digests; the hash only needs to spread passwords uniformly across prefixes so the returned lists stay manageable. Two old objections miss the point:

  • "SHA-1 is broken." Collisions let an attacker substitute one file for another. They do not let anyone reverse a random 160-bit digest of a password, and no one is verifying signatures here anyway.
  • "Rainbow tables." Precomputed tables could reverse a digest — but the digest never travels. Only 5 of its 40 hex characters do, and those 5 are shared by hundreds of entries in every response.

What k-anonymity hides — and what it does not

The honest version, because "your password never leaves the browser" on its own oversimplifies:

  • Hidden: the password, its full digest, and which specific password you are asking about. The prefix matches hundreds of entries in every response.
  • Not hidden: that you use the service (the server sees your IP and request timing), the exact prefix (20 bits of the digest), and — without padding — rough signals from response sizes. The API’s optional Add-Padding: true header pads replies with fake entries so lengths stop leaking that signal.
  • Out of scope: whether the password is strong. K-anonymity answers one question only: has this exact password appeared in known breaches.

A determined malicious API operator could also log prefixes over time. The mitigation is boring and real: HTTPS, an operator with some reputation to lose, and the fact that your prefix is shared by hundreds of passwords in every single response.

Where you already use it

The same model runs in tools you probably use daily: 1Password’s Watchtower and Bitwarden’s data breach report both check saved passwords against the Pwned Passwords corpus without sending the passwords to anyone. Our breach checker runs the four steps above entirely in your browser — one range request, visible in dev tools, nothing else.

Frequently asked

Is a k-anonymity password check safe to use?

Yes, with the caveats above: the provider learns a 5-character hash prefix and your connection metadata, not your password. For sensitive work, prefer a client-side implementation (as our tool uses) so the only third party involved is the range API itself.

What does the "k" in k-anonymity stand for?

k is the number of records an attacker must consider equally likely. If your request matches 812 hash suffixes, the service would have to guess 1-in-812 which one you actually hold — that 812 is your k.

Does k-anonymity mean my password is anonymous?

It means the lookup does not identify it. The password can still be weak, reused, or already public in a breach — finding that out is the point of the check. Anonymity of the query and safety of the password are different questions.

Why does the API return hundreds of hashes?

Because the corpus holds billions of passwords. Each 5-character hex prefix covers about one 1,048,576th of the hash space, so every prefix maps to hundreds of real entries. That volume is exactly the k in k-anonymity — thin responses would mean weak anonymity.

Can I run the check myself?

Yes. The API is free and the protocol is the four steps above: SHA-1 locally, first 5 hex characters to the range endpoint, match the returned suffixes locally. Any tool that does something different — sending the whole hash or the password — is not a k-anonymity password check.

See also: the breach checker tool (this protocol, live in your browser), credential stuffing for what attackers do with checked-but-reused passwords, and after a data breach for the full response plan.


Keep reading

Related articles

Browse all articles