Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Changes to make using the library a little easier and less typing. Al…
…so, getting ready to push to npm. Moved to nodeunit testing. Added a few tests...nothing special. Updated the readme and changed the licening to MIT. Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
- Loading branch information
Showing
8 changed files
with
125 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,19 @@ | ||
/* | ||
* Copyright (c) 2101, Nicholas Campbell <nicholas.j.campbell@gmail.com> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the <ORGANIZATION> nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
Copyright (c) 2010 Nicholas Campbell | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var bcrypt_lib = require('./bcrypt_lib'); | ||
|
||
module.exports = new bcrypt_lib.BCrypt(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "bcrypt", | ||
"description": "A bcrypt library for NodeJS.", | ||
"main": "./bcrypt", | ||
"version": "0.1.0", | ||
"author": "Nick Campbell (http://github.com/ncb000gt)", | ||
"engines": { "node": ">= 0.1.100" }, | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/ncb000gt/node.bcrypt.js.git" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT" | ||
} | ||
], | ||
"bugs": { | ||
"web" : "http://github.com/ncb000gt/node.bcrypt.js/issues" | ||
}, | ||
"dependencies": { | ||
"nodeunit": ">=0.3.1", | ||
}, | ||
"scripts": { | ||
"build" : "node-waf configure build", | ||
"test" : "node-waf test" | ||
"clean" : "node-waf clean" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var testCase = require('nodeunit').testCase, | ||
bcrypt = require('../bcrypt'); | ||
|
||
module.exports = testCase({ | ||
test_salt_length: function(assert) { | ||
var salt = bcrypt.gen_salt(10); | ||
assert.equals(29, salt.length, "Salt isn't the correct length."); | ||
assert.done(); | ||
}, | ||
test_salt_no_params: function(assert) { | ||
assert.throws(function() {bcrypt.gen_salt();}, "Should throw an Error. gen_salt requires # of rounds."); | ||
assert.done(); | ||
}, | ||
test_salt_rounds_is_string_number: function(assert) { | ||
assert.throws(function() {bcrypt.gen_salt('55');}, "Should throw an Error. No params."); | ||
assert.done(); | ||
}, | ||
test_salt_rounds_is_NaN: function(assert) { | ||
assert.throws(function() {bcrypt.gen_salt('b');}, "Should throw an Error. gen_salt requires rounds to be a number."); | ||
assert.done(); | ||
}, | ||
test_hashpw: function(assert) { | ||
assert.ok(bcrypt.hashpw('password', bcrypt.gen_salt(100)), "Should throw an Error. hash should not be null/undefined."); | ||
assert.done(); | ||
}, | ||
test_hash_pw_no_params: function(assert) { | ||
assert.throws(function() {bcrypt.hashpw();}, "Should throw an Error. No Params."); | ||
assert.done(); | ||
}, | ||
test_hash_pw_one_param: function(assert) { | ||
assert.throws(function() {bcrypt.hashpw('password');}, "Should throw an Error. No hash."); | ||
assert.done(); | ||
}, | ||
test_hash_pw_not_hash_str: function(assert) { | ||
assert.throws(function() {bcrypt.hashpw('password', 1);}, "Should throw an Error. hash should be a string."); | ||
assert.done(); | ||
}, | ||
test_hash_compare: function(assert) { | ||
var salt = bcrypt.gen_salt(10); | ||
assert.equals(29, salt.length, "Salt isn't the correct length."); | ||
var hash = bcrypt.hashpw("test", salt); | ||
assert.ok(bcrypt.compare("test", hash), "These hashes should be equal."); | ||
assert.ok(!(bcrypt.compare("blah", hash)), "These hashes should not be equal."); | ||
assert.done(); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters