Comparing version 0.7.7 to 0.7.8
106
bcrypt.js
@@ -0,14 +1,10 @@ | ||
'use strict'; | ||
var bindings = require('bindings')('bcrypt_lib'); | ||
var crypto = require('crypto'); | ||
/// generate a salt (sync) | ||
/// @param {Number} [rounds] number of rounds (default 10) | ||
/// @param {Number} [seed_length] number of random bytes (default 20) | ||
/// @return {String} salt | ||
module.exports.gen_salt_sync = function(rounds, seed_length) { | ||
console.log("DEPRECATION WARNING: `gen_salt_sync` has been deprecated. Please use `genSaltSync` instead."); | ||
return module.exports.genSaltSync(rounds, seed_length); | ||
} | ||
module.exports.genSaltSync = function(rounds, seed_length) { | ||
module.exports.genSaltSync = function(rounds) { | ||
// default 10 rounds | ||
@@ -21,10 +17,3 @@ if (!rounds) { | ||
// default length 20 | ||
if (!seed_length) { | ||
seed_length = 20; | ||
} else if (typeof seed_length !== 'number') { | ||
throw new Error('seed_length must be a number'); | ||
} | ||
return bindings.gen_salt_sync(rounds, seed_length); | ||
return bindings.gen_salt_sync(rounds, crypto.randomBytes(16)); | ||
}; | ||
@@ -34,11 +23,4 @@ | ||
/// @param {Number} [rounds] number of rounds (default 10) | ||
/// @param {Number} [seed_length] number of random bytes (default 20) | ||
/// @param {Function} cb callback(err, salt) | ||
module.exports.gen_salt = function(rounds, seed_length, cb) { | ||
console.log("DEPRECATION WARNING: `gen_salt` has been deprecated. Please use `genSalt` instead."); | ||
return module.exports.genSalt(rounds, seed_length, cb); | ||
} | ||
module.exports.genSalt = function(rounds, seed_length, cb) { | ||
module.exports.genSalt = function(rounds, ignore, cb) { | ||
// if callback is first argument, then use defaults for others | ||
@@ -49,3 +31,2 @@ if (typeof arguments[0] === 'function') { | ||
rounds = 10; | ||
seed_length = 20; | ||
// callback is second argument | ||
@@ -55,3 +36,2 @@ } else if (typeof arguments[1] === 'function') { | ||
cb = arguments[1]; | ||
seed_length = 20; | ||
} | ||
@@ -66,9 +46,2 @@ | ||
// default length 20 | ||
if (!seed_length) { | ||
seed_length = 20; | ||
} else if (typeof seed_length !== 'number') { | ||
return cb(new Error('seed_length must be a number')); | ||
} | ||
if (!cb) { | ||
@@ -78,3 +51,3 @@ return; | ||
return bindings.gen_salt(rounds, seed_length, cb); | ||
return bindings.gen_salt(rounds, crypto.randomBytes(16), cb); | ||
}; | ||
@@ -86,12 +59,8 @@ | ||
/// @return {String} hash | ||
module.exports.encrypt_sync = function(data, salt) { | ||
console.log("DEPRECATION WARNING: `encrypt_sync` has been deprecated. Please use `hashSync` instead."); | ||
return module.exports.hashSync(data, salt); | ||
} | ||
module.exports.hashSync = function(data, salt) { | ||
if (data == null || data == undefined || salt == null || salt == undefined) { | ||
if (data == null || salt == null) { | ||
throw new Error('data and salt arguments required'); | ||
} else if (typeof data !== 'string' && (typeof salt !== 'string' || typeof salt !== 'number')) { | ||
} | ||
if (typeof data !== 'string' || (typeof salt !== 'string' && typeof salt !== 'number')) { | ||
throw new Error('data must be a string and salt must either be a salt string or a number of rounds'); | ||
@@ -101,3 +70,3 @@ } | ||
if (typeof salt === 'number') { | ||
salt = module.exports.genSaltSync(salt); | ||
salt = module.exports.genSaltSync(salt); | ||
} | ||
@@ -112,8 +81,2 @@ | ||
/// @param {Function} cb callback(err, hash) | ||
module.exports.encrypt = function(data, salt, cb) { | ||
console.log("DEPRECATION WARNING: `encrypt` has been deprecated. Please use `hash` instead."); | ||
return module.exports.hash(data, salt, cb); | ||
} | ||
module.exports.hash = function(data, salt, cb) { | ||
@@ -123,8 +86,12 @@ if (typeof data === 'function') { | ||
} | ||
if (typeof salt === 'function') { | ||
return salt(new Error('data must be a string and salt must either be a salt string or a number of rounds')); | ||
} | ||
if (data == null || data == undefined || salt == null || salt == undefined) { | ||
if (data == null || salt == null) { | ||
return cb(new Error('data and salt arguments required')); | ||
} else if (typeof data !== 'string' && (typeof salt !== 'string' || typeof salt !== 'number')) { | ||
} | ||
if (typeof data !== 'string' || (typeof salt !== 'string' && typeof salt !== 'number')) { | ||
return cb(new Error('data must be a string and salt must either be a salt string or a number of rounds')); | ||
@@ -138,5 +105,5 @@ } | ||
if (typeof salt === 'number') { | ||
return module.exports.genSalt(salt, function(err, salt) { | ||
return bindings.encrypt(data, salt, cb); | ||
}); | ||
return module.exports.genSalt(salt, function(err, salt) { | ||
return bindings.encrypt(data, salt, cb); | ||
}); | ||
} | ||
@@ -151,12 +118,8 @@ | ||
/// @return {bool} true if hashed data matches hash | ||
module.exports.compare_sync = function(data, hash) { | ||
console.log("DEPRECATION WARNING: `compare_sync` has been deprecated. Please use `compareSync` instead."); | ||
return module.exports.compareSync(data, hash); | ||
} | ||
module.exports.compareSync = function(data, hash) { | ||
if (data == null || data == undefined || hash == null || hash == undefined) { | ||
if (data == null || hash == null) { | ||
throw new Error('data and hash arguments required'); | ||
} else if (typeof data !== 'string' || typeof hash !== 'string') { | ||
} | ||
if (typeof data !== 'string' || typeof hash !== 'string') { | ||
throw new Error('data and hash must be strings'); | ||
@@ -173,5 +136,7 @@ } | ||
module.exports.compare = function(data, hash, cb) { | ||
if (data == null || data == undefined || hash == null || hash == undefined) { | ||
if (data == null || hash == null) { | ||
return cb(new Error('data and hash arguments required')); | ||
} else if (typeof data !== 'string' || typeof hash !== 'string') { | ||
} | ||
if (typeof data !== 'string' || typeof hash !== 'string') { | ||
return cb(new Error('data and hash must be strings')); | ||
@@ -189,12 +154,8 @@ } | ||
/// @return {Number} the number of rounds used to encrypt a given hash | ||
module.exports.get_rounds = function(hash) { | ||
console.log("DEPRECATION WARNING: `get_rounds` has been deprecated. Please use `getRounds` instead."); | ||
return module.exports.getRounds(hash); | ||
} | ||
module.exports.getRounds = function(hash) { | ||
if (hash == null || hash == undefined) { | ||
if (hash == null) { | ||
throw new Error('hash argument required'); | ||
} else if (typeof hash !== 'string') { | ||
} | ||
if (typeof hash !== 'string') { | ||
throw new Error('hash must be a string'); | ||
@@ -205,2 +166,1 @@ } | ||
}; | ||
@@ -14,4 +14,4 @@ { | ||
"main": "./bcrypt", | ||
"version": "0.7.7", | ||
"author": "Nick Campbell (http://github.com/ncb000gt)", | ||
"version": "0.7.8", | ||
"author": "Nick Campbell (https://github.com/ncb000gt)", | ||
"engines": { | ||
@@ -22,3 +22,3 @@ "node": ">= 0.6.0" | ||
"type": "git", | ||
"url": "http://github.com/ncb000gt/node.bcrypt.js.git" | ||
"url": "https://github.com/ncb000gt/node.bcrypt.js.git" | ||
}, | ||
@@ -31,3 +31,3 @@ "licenses": [ | ||
"bugs": { | ||
"url": "http://github.com/ncb000gt/node.bcrypt.js/issues" | ||
"url": "https://github.com/ncb000gt/node.bcrypt.js/issues" | ||
}, | ||
@@ -34,0 +34,0 @@ "scripts": { |
@@ -12,19 +12,14 @@ # node.bcrypt.js | ||
Because we can't magically know what you are doing to expose an issue, it is best if you provide a snippet of code. This snippet need not include your secret sauce, but it must replicate the issue you are describing. The issues that get closed without resolution tend to be the ones without code examples. Thanks. | ||
First, make sure that the version of node you are using is a _stable_ version. You'll know this because it'll have an even major release number. We do not currently support unstable versions and while the module may happen to work on some unstable versions you'll find that we quickly close issues if you're not using a stable version. | ||
If you are on a stable version of node, we can't magically know what you are doing to expose an issue, it is best if you provide a snippet of code or log files if you're having an install issue. This snippet need not include your secret sauce, but it must replicate the issue you are describing. The issues that get closed without resolution tend to be the ones that don't help us help you. Thanks. | ||
## Version Compatability | ||
<table> | ||
<tr> | ||
<td>Node Ver</td><td>Bcrypt Version</td> | ||
</tr> | ||
<tr> | ||
<td><= 0.4.x</td><td><= 0.4.x</td> | ||
</tr> | ||
<tr> | ||
<td>>= 0.6.x</td><td>>= 0.5.x</td> | ||
</tr> | ||
</table> | ||
## Version Compatibility | ||
| Node Version | Bcrypt Version | | ||
| ---- | ---- | | ||
| <= 0.4.x | <= 0.4.x | | ||
| >= 0.6.x | >= 0.5.x | | ||
Windows users should make sure to have at least node 0.8.5 installed and version >= 0.7.1 of this module. | ||
@@ -48,7 +43,2 @@ `node-gyp` only works with stable/released versions of node. Since the `bcrypt` module uses `node-gyp` to build and install you'll need a stable version of node to use bcrypt. If you do not you'll likely see an error that starts with: | ||
* NodeJS | ||
* OpenSSL (Development Libraries (header files) for compilation) | ||
* For Windows you'll need http://slproweb.com/products/Win32OpenSSL.html installed to the default location of `C:\OpenSSL-Win32` | ||
* When installing OpenSSL, you must tell it to put DLLs in `The Windows system directory` to avoid `The specified module could not be found.` errors. | ||
* Please note that for this to build properly you'll need the Normal version of OpenSSL-Win<arch>, not the Light version. The reason for this is that we need to be able to compile the code using the header files that exist in the Normal version. | ||
* For 64 bit use the 64 bit version and install to `C:\OpenSSL-Win64` | ||
* `node-gyp` | ||
@@ -64,2 +54,4 @@ * Please check the dependencies for this tool at: https://github.com/TooTallNate/node-gyp/ | ||
***Note:*** OS X users using Xcode 4.3.1 or above may need to run the following command in their terminal prior to installing if errors occur regarding xcodebuild: ```sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer``` | ||
## Usage | ||
@@ -129,8 +121,6 @@ | ||
* `genSaltSync(rounds, seed_length)` | ||
* `genSaltSync(rounds)` | ||
* `rounds` - [OPTIONAL] - the number of rounds to process the data for. (default - 10) | ||
* `seed_length` - [OPTIONAL] - RAND_bytes wants a length. to make that a bit flexible, you can specify a seed_length. (default - 20) | ||
* `genSalt(rounds, seed_length, cb)` | ||
* `genSalt(rounds, cb)` | ||
* `rounds` - [OPTIONAL] - the number of rounds to process the data for. (default - 10) | ||
* `seed_length` - [OPTIONAL] - RAND_bytes wants a length. to make that a bit flexible, you can specify a seed_length. (default - 20) | ||
* `cb` - [REQUIRED] - a callback to be fired once the salt has been generated. uses eio making it asynchronous. | ||
@@ -137,0 +127,0 @@ * `err` - First parameter to the callback detailing any errors. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81029
18
521
210