1.0.0 • Published 1 year ago
pwd-shaker v1.0.0
pwd-shaker is a node.js library simpifying some routine tasks related to one-way password encryption (hash computing).
It is totally based on the standard crypto module and use no external dependencies.
As the basic feature here is to apply so called salt and pepper, it's named after the related condiment dispensers.
The library features two classes:
- PasswordShaker implementing basic functionality;
- PasswordShakerFile, the derived class with
pepperkept in a file instead of RAM.
Installation
npm install pwd-shakerUsage
const {PasswordShakerFile} = require ('pwd-shaker')
const shaker = new PasswordShakerFile ({
path : '/etc/this_information_system/secret_pepper',
// order : ['pepper', 'salt', 'pwd'],
// algorithm : 'sha256',
// encoding : 'hex',
})
const {login, pwd} = //...available from input
const salt = shaker.sprinkle (32)
const hash = shaker.cook (pwd, salt)
// store login+hash+salt instead of login+pwd
//...then...
const {login, pwd} = //...available from input
const {hash, salt} = //...fetch by login
if (shaker.test (hash, pwd, salt)) {
// auth OK
}
else {
// kick out
}1.0.0
1 year ago