
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Install locally:
npm install ./bhash
Or from npm:
npm install bhash
const bhash = require('./bhash'); // Local
// OR
// const bhash = require('bhash'); // From npm
Sync:
const salt = bhash.genSaltSync(12); // 12 rounds
console.log('Salt:', salt);
Async:
bhash.genSalt(12, (err, salt) => {
if (err) throw err;
console.log('Salt:', salt);
});
Sync:
const password = 'MySuperSecret!123';
const salt = bhash.genSaltSync();
const hash = bhash.hashSync(password, salt);
console.log('Hash:', hash);
Async:
bhash.genSalt(10, (err, salt) => {
bhash.hash('MySuperSecret!123', salt, (err, hash) => {
if (err) throw err;
console.log('Hash:', hash);
});
});
Sync:
const isMatch = bhash.compareSync('MySuperSecret!123', hash);
console.log('Password match:', isMatch); // true
Async:
bhash.compare('MySuperSecret!123', hash, (err, matched) => {
if (err) throw err;
console.log('Password match:', matched); // true or false
});
const strong = bhash.checkPasswordStrength('MySuperSecret!123');
console.log('Is strong password?', strong); // true or false
const safe = bhash.timingSafeEqual(hash, hash2);
console.log('Timing safe equal:', safe);
const rounds = bhash.getRounds(hash);
console.log('Rounds used:', rounds);
const version = bhash.getHashVersion(hash);
console.log('Hash version:', version); // e.g. '2b'
Generates a salt synchronously. rounds is the work factor (default: 10).
Generates a salt asynchronously. Callback receives (err, salt).
Hashes a password synchronously with the given salt.
Hashes a password asynchronously. Callback receives (err, hash).
Compares a password to a hash synchronously. Returns true or false.
Compares a password to a hash asynchronously. Callback receives (err, matched).
Extracts the number of rounds used from a hash.
Performs a timing-safe comparison between two strings or buffers.
Checks if a password is strong (min 8 chars, upper, lower, number, special).
Returns the hash version (e.g. '2b') from a hash string.
bhash.js: Main entry point (exports everything from src/index.js)src/index.js: All core logic and featuresREADME.md: Full documentationpackage.json: Project metadata and scriptsMIT — Free for personal and commercial use.
Developed by Muhammad Wajid Ashraf — Software Engineer
Made with ❤️ by Muhammad Wajid Ashraf
FAQs
A lightweight bcrypt alternative for password hashing and verification
We found that bhash demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.