Skip to content

Commit

Permalink
Updated ReadMe, moved logo into repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Marak committed Jan 28, 2011
1 parent 9b1ce0b commit d8c613f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#node_hash - a super simple hashing library for node.js
## supports md5, sha1, sha256, sha512, ripemd160

<img border = "0" src = "http://imgur.com/diDP0.jpg"/>
<img border = "0" src = "https://github.com/Marak/node_hash/raw/master/logo.jpg"/>

##what is a hash?

Expand All @@ -23,7 +23,7 @@ now, instead of seeing a human readable format, you will see an obfuscated strin

everytime you want to check if a value matches that hash (in this case, perhaps a login form handler), you can simply call the same hashing method on that value and compare it to the value in your database. if the hashes match, the passwords match.

you can also provide an optional "salt" that will further encrypt your password, making it even harder to reverse / crack.
you can also provide an optional "salt" that will further encrypt your password, making it even harder to reverse / crack. you should use a unique salt for every password and store that salt.

##usage

Expand All @@ -33,7 +33,7 @@ you can also provide an optional "salt" that will further encrypt your password,
// a user's password, hash this please
var user_password = "password";

// don't expose your salt
// don't expose your salt ( you should use a new salt for every password )
var salt = "sUp3rS3CRiT$@lt";


Expand Down
2 changes: 1 addition & 1 deletion lib/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ crypto = require('crypto'),
algos = ["sha1", "md5", "sha256", "sha512", "ripemd160"],
encoding = "hex";

algos.forEach( function( algo) {
algos.forEach( function( algo ) {
exports[ algo ] = function(data, salt) {
var hash;
if( typeof salt != 'undefined'){
Expand Down
Binary file added logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 17 additions & 2 deletions node-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,31 @@
var user_password = "password";

// don't expose your salt
var salt = "sUp3rS3CRiT$@lt";
var salt = "sUp3rS3CRiT$@lt"; // change this per hash


/****** md5 ******/
/****** md5 hex ******/
var md5 = hash.md5(user_password);
sys.puts(md5);

var salted_md5 = hash.md5(user_password, salt);
sys.puts(salted_md5);


/****** md5 utf-8 ******/
var md5 = hash.md5(user_password);
sys.puts(md5);

var salted_md5 = hash.md5(user_password, salt);
sys.puts(salted_md5);

/****** md5 binary ******/
var md5 = hash.md5(user_password);
sys.puts(md5);

var salted_md5 = hash.md5(user_password, salt);
sys.puts(salted_md5);

/****** sha1 ******/
var sha1 = hash.sha1(user_password);
sys.puts(sha1);
Expand Down

0 comments on commit d8c613f

Please sign in to comment.