password-encrypter
v0.0.2
Published
Utilises node.js's crypto module to encrypt passwords with a salt.
Downloads
2
Readme
Crypto Password
Utilises node.js's crypto module to encrypt passwords with a salt.
Very simple to use and helps creates salts and password hashes to be entered into the database, for security. Because you know, storing passwords in raw form, or even without a salt is very bad practice.
Usage:
var passwordEncrypter = require('password-encrypter');
passwordEncrypter.encrypt("password123!", function (salt, hashedPassword) {
// do whatever you want with the salt and hashedPassword;
});
There is no real way to decrypt the password, so the only way is to encrypt and check. To check if encrypted password is correct:
passwordEncrypter.checkMatch("password123!", "HASHED_PASSWORD", "MY_SALT", function (err, isMatch) {
if (isMatch) {
// success! the passwords are correct! Assign sessions/cookies to user and authenticate
} else {
// Boo! Wrong password.
}
});