encryption-p
is a lightweight password hashing library written in TypeScript, similar to bcrypt. It provides simple utilities for securely hashing and comparing passwords using Node.js' crypto
module.
- Secure password hashing using
pbkdf2Sync
. - Customizable salt rounds.
- Easy-to-use API for hashing and comparing passwords.
Install the package using npm:
npm install encryption-p
import { MyBcrypt } from "encryption-p";
const password = "mysecretpassword";
const hashedPassword = MyBcrypt.hash(password);
console.log(hashedPassword); // Outputs hashed password with salt
import { MyBcrypt } from "encryption-p";
const password = "mysecretpassword";
const hashedPassword = "stored_hashed_password";
const isMatch = MyBcrypt.compare(password, hashedPassword);
if (isMatch) {
console.log("Password matches!");
} else {
console.log("Invalid password.");
}
Hashes the provided password using the given number of salt rounds (default is 10). Returns the hashed password along with the salt.
password
- The plain text password to be hashed.saltRounds
- (Optional) Number of salt rounds to apply.
Compares a plain text password with a previously hashed password. Returns true
if the password matches, otherwise false
.
password
- The plain text password to compare.hash
- The hashed password to compare against.
This project is licensed under the MIT License.
<<<<<<< HEAD
======= >>>>>>> 09dce16c01c8dfa617e30f55c85bf8315a9b1dfe