Package Exports
- scurvy
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (scurvy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
scurvy
A reusable node.js module for handling user registration and login scenarios.
MIT License
version 0.0.1, experimental
Install
npm install scurvy --saveRunning Tests
npm testUsage
var scurvy = require('scurvy');
var my_secure_password = 'password01'; //uber secure
var salt = "";
var hashed_password = "";
var validated = false;
function main() {
hashPassword(function() {
validate_credentials(function() {
console.log("Does it match? " + validated);
});
});
}
function hashPassword(callback) {
//Generate a salt and hash from a password.
scurvy.generateNewHash(my_secure_password, function (err, result) {
salt = result.salt;
hashed_password = result.hash;
callback();
}
}
function validate_credentials(callback) {
scurvy.comparePlaintextToHash(my_secure_password, hash, function(err, matches) {
validated = matches;
callback();
});
}
API
scurvy.generateNewHash(input, callback)
Creates a 60 character hash and 29 character salt from input. Calls callback when complete with method signature function (err, result). err is null when there is no error. result is an object with two fields salt and hash that are created by the hashing algorithm. Asynchronous.
comparePlaintextToHash(inputPassword, hash, callback)
Takes an inputPassword`` and hashthat was created with generateNewHash() (where inputPassword was the input) and returns acallbackwith method signaturefunction(err, matches)whereerris null when there is no error, andmatches``` is true if the parameters validate,
scurvy.setRounds(rounds)
Optional function. Internally, rounds defaults to 10.
rounds Must be integer > 0.
TODO: #generateMetastateHashkey(),#validateMetastateHashkey()