ShieldX Toolly
Open a tool Donate
Home Home
Blog Blog
FAQ FAQ
Open a tool Donate
All guides
Intermediate 5 min Passwords

Breach Checker Guide

K-anonymity breach checking with Have I Been Pwned

Sections
3
Level
Intermediate
Read
5 min
Section 01

What is k-anonymity?

K-anonymity is a privacy model that ensures you cannot be distinguished from at least k-1 other individuals. In the context of breach checking, ShieldX uses the Have I Been Pwned (HIBP) API with a k-anonymity model: only the first 5 characters of your password's SHA-1 hash are sent to the server.

With 5 hex characters, there are 16^5 = 1,048,576 possible prefixes. The server returns all breach entries matching that prefix — potentially hundreds of hashes. Your full hash is compared locally, so the server never knows which specific password you checked.

Section 02

Step-by-step: checking a password safely

  1. SHA-1 hash the password locally in your browser
  2. Take the first 5 characters of the hex hash
  3. Send only those 5 characters to the HIBP API
  4. Receive all matching hash suffixes with breach counts
  5. Compare your full hash locally against the returned list
  6. Report the breach count if matched, nothing otherwise
                          async function checkBreach(password: string): Promise<number> {
  // 1. Hash locally
  const data = new TextEncoder().encode(password);
  const hashBuf = await crypto.subtle.digest('SHA-1', data);
  const fullHash = [...new Uint8Array(hashBuf)]
    .map((b) => b.toString(16).padStart(2, '0')).join('');

  // 2. Send only first 5 chars
  const prefix = fullHash.slice(0, 5).toUpperCase();
  const res = await fetch(
    `https://api.pwnedpasswords.com/range/${prefix}`
  );
  const text = await res.text();

  // 3. Compare locally
  const suffix = fullHash.slice(5).toUpperCase();
  const match = text
    .split('\n')
    .find((line) => line.startsWith(suffix));
  return match ? parseInt(match.split(':')[1]) : 0;
}
                        
Section 03

Why this is safe

TipThe server sees only a 5-character prefix shared by ~1 million other hashes. It cannot determine your password, your full hash, or even if your password was found in a breach.

WarningNever send your plaintext password to any breach checking service. Always verify that the tool hashes locally first — you can check the network tab to confirm only the hash prefix is transmitted.

Put it into practice

Try Breach Checker right now

Every concept in this guide is implemented in ShieldX. Open the tool, watch the network tab stay empty, and verify the security yourself.

Open Breach Checker

No signup · No cookies · No cost · secure.toolly.site