crypto-password-helper
Helper for encrypting and generating password using crypto in node.js. The encryption is made using cryptos pbkdf2 method. Salt, iterations and digest is automatically added to the password hash so no need to save anything but the returned hash.
Installation
Install via NPM using command:
$ npm install --save crypto-password-helper
Usage
The hash is always returned via a promise as a string (URL-safe). Two simple methods are available from the password helper, usage below:
var password = ; // Using default configurationpassword; // handle internal server error. (crypto error) // Using your own configurationpassword; // handle internal server error. (crypto error) // Generate password-hash synchronous. (with options) - throws on errorlet hash = password; // Generate password-hash synchronous. (without options) - throws on errorlet hash = password; // Check if password matchpassword; // Handle internal server error. (crypto error) // Compare synchronous. (Throws on error)let isMatch = password;
Configuration
There are four values that are configurable. See below for default configuration. All settings are adjustable.
let defaults = // Number of iterations (higher number -> more secure but takes longer time to complete.) iterations: 612484 // Number of bytes for the password hash. hashSize: 32 // Number of bytes for the password salt. saltSize: 16 // The digest used to hash the password. See list of digests for crypto. digest: 'sha512'
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
License
MIT © Tommy Dronkers