0.0.2 • Published 11 years ago

hshbrwn v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
11 years ago

hshbrwn

A super simple module to hash and validate data. It only has two functions: generate to create the hash and validate to check if the given data matches the hash.

Hashing is important as it allows you to store your data, such as passwords, fairly securely, so in the event your database is compromised, the hacker will have a very hard time actually decoding the users's data.

How to Use

First, install it in your project with:

npm install hshbrwn

Next, require the module, generate the hash, and store it in your database.

var hshbrwn = require("hshbrwn");

// you put this in your sign-up POST request function, for example
var password = "ihearthashbrowns";
var hash = hshbrwn.generate(password);

/**
 * Now you can store the `hash` value in a safe place
 */

Finally, when it comes time to check if the data (in this example, the password) is correct, we can check it against the hash.

var hshbrwn = require("hshbrwn");

// you put this in your log-in POST request function, for example
var password = "ihearthashbrowns";
var hash = "1ideYkaDcbRo30w65jjxbdy9a"; // example hash - this value is the hash you stored in the db earlier

if (hshbrwn.validate(hash, password)) {
  // success!
} else {
  // the hash does not match the password
}
0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago