
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
pwnedpasswords
Advanced tools
A wrapper for PwnedPasswords API by Troy Hunt (haveibeenpwned.com).
A dependency-free Node.js module for interfacing with the PwnedPasswords API by Troy Hunt (haveibeenpwned.com).
This module implements the new and improved version 2 of the API. This version of the API implements k-Anonymity and does NOT send even the hashed version of the passwords to third party. It only sends the first 5 characters of the SHA-1 hash. You can read more about it in the Troy Hunt's blog announcement post.
The reason I chose not to use any dependencies (e.g. request
or got
) is first, because it is a pretty simple API and can be handled easily by the built-in https
module. But mainly, it is for security reasons. Dependency chain can get deep and unpredictable. One rogue module down the chain can intercept requests and hand over passwords elsewhere.
Please review the code before use.
Install and save exact module version, to avoid installing, another, potentially vulnerable version in the future.
If you need to upgrade, again, review the code and upgrade to an exact version you have witnessed yourself.
npm install --save-exact pwnedpasswords
The module implements three interfaces. Callback, promises and CLI.
Return value is an integer with a count of input password prevalence.
Zero (0
) is returned when the password is not found.
const pwnedpasswords = require('pwnedpasswords')
pwnedpasswords('password')
.then(count => {
console.log('Password was found %d times.', count)
})
.catch(err => {
console.error(err)
})
const pwnedpasswords = require('pwnedpasswords')
pwnedpasswords('password', (err, count) => {
if (err) {
console.error(err)
}
console.log('Password was found %d times.', count)
})
It is not recommended to use this command with real passwords, as you are exposing the password to the process list and shell history. But this can be used for testing and educational scenarios or in other shell scripts.
$> ./node_modules/.bin/pwnedpasswords password
3730471
Or if installed globally, then run:
$> pwnedpasswords password
3730471
Or via npx
:
$> npx -q pwnedpasswords password
3730471
None
MIT
FAQs
A wrapper for PwnedPasswords API by Troy Hunt (haveibeenpwned.com).
The npm package pwnedpasswords receives a total of 205 weekly downloads. As such, pwnedpasswords popularity was classified as not popular.
We found that pwnedpasswords demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.