When users want to check whether a password has been leaked in a data breach, pasting it into a standard form that sends the plaintext string to a backend server is a major security anti-pattern.
Fortunately, you can build a zero-knowledge password audit tool directly in the browser using the native Web Crypto API ( crypto.subtle ) and the k-Anonymity range model —with zero external dependencies.
How the k-Anonymity Range Model Works
Instead of transmitting a password or even its full hash over the network, the client only shares a 5-character hash prefix:
Hash Locally: Compute the SHA-1 digest of the password inside the browser.
Split the Digest: Take the first 5 hex characters ( prefix ) and keep the remaining 35 characters ( suffix ) in local memory.
Query the Range API: Send only the 5-character prefix to https://api.pwnedpasswords.com/range/{prefix} .
Compare Locally: The API returns hundreds of matching hash suffixes alongside breach counts.…