Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated ReadMe, moved logo into repo

  • Loading branch information...
commit d8c613ff81d5bee8c6cb1eb9747f9226ff319554 1 parent 9b1ce0b
Marak authored
6 ReadMe.md
View
@@ -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?
@@ -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
@@ -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";
2  lib/hash.js
View
@@ -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'){
BIN  logo.jpg
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 node-demo.js
View
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.