node-password-storage
v1.0.4
Published
The best way to protect passwords is to employ salted password hashing.
Downloads
6
Readme
Node Password Storage
Generated by OSS Project Generator.
The best way to protect passwords is to employ salted password hashing.
Installation
Prerequsites
Install package:
$ npm install --save node-password-storage
Usage
- Generate a salt
const lib = require('node-password-storage');
const salt_size = 32;
lib.generateSalt(salt_size, (err, salt) => {
if (err) return console.error(err);
console.log(`SALT: ${salt.toString('hex')}\n`);
});
- Generate a hash
const lib = require('node-password-storage');
const password = 'password';
const salt = 'salt';
lib.generateHash(password, salt, (err, hash) => {
if (err) return console.error(err);
console.log(`HASH: ${hash.toString('hex')}\n`);
});
- To generate and compare a storage
const lib = require('node-password-storage');
const password = 'password';
lib.generateStorage(password, (err, storage) => {
if (err) return console.error(err.message);
const params = storage.split(':');
console.log(`SALT => ${params[0]}`);
console.log(`HASH => ${params[1]}`);
lib.verifyStorage(password, storage, (err, success) => {
if (err) return console.error(err);
console.log(`MATCH: ${success}`);
});
});
Development
- Clone the repo
$ git clone https://github.com/robertoachar/node-password-storage.git
- Install dependencies
$ npm install
| Action | Usage |
| ---------------------------------------- | ------------------- |
| Starting development mode | npm start
|
| Linting code | npm run lint
|
| Running unit tests | npm run jest
|
| Running code coverage | npm run coverage
|
| Running lint + tests | npm test
|
| Sending coverage results to Coveralls.io | npm run coveralls
|