Checking Passwords for Breaches in the Browser With Web Crypto and k-Anonymity
A DEV Community author describes a method for checking whether a password appears in data breaches without exposing it. The browser computes a SHA-1 hash of the password locally using the Web Crypto API. Only the first five hash characters are sent to the Pwned Passwords range API, while the remaining suffix is compared on the client side. Because many hashes share each prefix, the server cannot determine which password was checked. The article also recommends keeping password inputs out of analytics and logs, using strict CSP headers, and rotating reused credentials if a match is found.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in