@rojo2/password
v1.1.1
Published
Library to do safe password hashing using PBKDF2
Downloads
4
Readme
Password
Password hash library using PBKDF2.
import password from "@rojo2/password";
// Hash password
const hashedPassword = await password.hash("plainPassword")
// Verify password
const result = await password.verify("plainPassword", "hashedPassword");
if (result === true) {
// Password is ok.
} else {
// Passwords doesn't match.
}
Or if you prefer promises:
import password from "@rojo2/password";
// Hash password
password.hash("plainPassword").then((hashedPassword) => {
// ... do something with the hashed password (like saving it in a mongodb object) ...
}).catch((error) => {
// ...
});
// Verify password
password.verify("plainPassword", "hashedPassword").then((result) => {
if (result === true) {
// Password is ok.
} else {
// Passwords doesn't match.
}
}).catch((error) => {
// ...
});
Made with ❤ by ROJO 2 (http://rojo2.com)