
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@mongez/password
Advanced tools
A Simple Password Hash Generator and Verifier for Node Js
This package is a wrapper over bcryptjs as it is being used to generate and verify passwords.
yarn add @mongez/password
Or
npm i @mongez/password
To generate a password hash, just import the Package and call the generate method.
import Password from '@mongez/password';
// generate a password hash
const hash = await Password.generate('123456');
console.log(hash); // $2a$15$Yw76mQjsULdRb14qtBZ7Y.iMkJNrbewQ4cpX/PPP0nt4wQuUo70Fu
Alternatively, you can use the hash method.
import { hash } from '@mongez/password';
// generate a password hash
const hash = hash('123456');
console.log(hash); // $2a$15$Yw76mQjsULdRb14qtBZ7Y.iMkJNrbewQ4cpX/PPP0nt4wQuUo70Fu
To verify a password, just import the Package and call the verify method.
import Password from '@mongez/password';
// verify a password
const isValid = await Password.verify('123456', '$2a$15$Yw76mQjsULdRb14qtBZ7Y.iMkJNrbewQ4cpX/PPP0nt4wQuUo70Fu'); // true
Or you can import directly the verify method.
import { verify } from '@mongez/password';
// verify a password
const isValid = verify('123456', '$2a$15$Yw76mQjsULdRb14qtBZ7Y.iMkJNrbewQ4cpX/PPP0nt4wQuUo70Fu'); // true
By default the generated password has value of salt equals to 15 but you can change it by passing the salt option.
import Password from '@mongez/password';
// generate a password hash
const hash = await Password.generate('123456', 10);
console.log(hash); // $2a$10$Yw76mQjsULdRb14qtBZ7Y.iMkJNrbewQ4cpX/PPP0nt4wQuUo70Fu
Or you can change the default salt value directly using setDefaultPasswordSalt method.
import Password, { setDefaultPasswordSalt } from '@mongez/password';
// set default salt
setDefaultPasswordSalt(10);
// generate a password hash
const hash = await Password.generate('123456'); // will be generated with salt equals to 10
To run the tests, just run the following command:
yarn test
This package is open-sourced software licensed under the MIT license.
FAQs
A password hash generator and verifier for Nodejs.
We found that @mongez/password 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
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.