Comparing version
@@ -6,3 +6,3 @@ { | ||
"main": "./bcrypt", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"author": "Nick Campbell (http://github.com/ncb000gt)", | ||
@@ -9,0 +9,0 @@ "engines": { "node": ">= 0.4.0" }, |
@@ -48,8 +48,7 @@ node.bcrypt.js | ||
var hash = bcrypt.encrypt_sync("B4c0/\/", salt); | ||
// Store hash in your password DB. | ||
To check a password: | ||
var bcrypt = require('bcrypt'); | ||
var salt = bcrypt.gen_salt_sync(10); | ||
var hash = bcrypt.encrypt_sync("B4c0/\/", salt); | ||
// Load hash from your password DB. | ||
bcrypt.compare_sync("B4c0/\/", hash); // true | ||
@@ -66,3 +65,3 @@ bcrypt.compare_sync("not_bacon", hash); // false | ||
bcrypt.encrypt("B4c0/\/", salt, function(err, hash) { | ||
//something | ||
// Store hash in your password DB. | ||
}); | ||
@@ -73,13 +72,9 @@ }); | ||
var bcrypt = require('bcrypt'); | ||
bcrypt.gen_salt(10, function(err, salt) { | ||
bcrypt.encrypt("B4c0/\/", salt, function(err, hash) { | ||
bcrypt.compare("B4c0/\/", hash, function(err, res) { | ||
// res == true | ||
}); | ||
bcrypt.compare("not_bacon", hash, function(err, res) { | ||
// res = false | ||
}); | ||
}); | ||
// Load hash from your password DB. | ||
bcrypt.compare("B4c0/\/", hash, function(err, res) { | ||
// res == true | ||
}); | ||
bcrypt.compare("not_bacon", hash, function(err, res) { | ||
// res = false | ||
}); | ||
@@ -86,0 +81,0 @@ API |
@@ -13,5 +13,9 @@ var testCase = require('nodeunit').testCase, | ||
test_salt_no_params: function(assert) { | ||
assert.throws(function() {bcrypt.gen_salt();}, "Should throw an Error. gen_salt requires # of rounds."); | ||
assert.throws(function() {bcrypt.gen_salt();}, "Should throw an Error. gen_salt requires a callback."); | ||
assert.done(); | ||
}, | ||
test_salt_only_cb: function(assert) { | ||
assert.doesNotThrow(function() {bcrypt.gen_salt(function(err, salt) {});}, "Should not throw an Error. Rounds and seed length are optional."); | ||
assert.done(); | ||
}, | ||
test_salt_rounds_is_string_number: function(assert) { | ||
@@ -18,0 +22,0 @@ assert.throws(function() {bcrypt.gen_salt('10');}, "Should throw an Error. No params."); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
306
1.32%73407
-0.07%172
-2.82%