scurvy

A reusable node.js module for handling user registration and login scenarios.

scurvy

A reusable node.js module for handling user registration and login scenarios.

MIT License

version 0.0.1, experimental

npm install scurvy --save
npm test
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();
    });
}
 

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`` andhashthat 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()