Skip to content

Commit f895e1f

Browse files
committed
Further improve compatibility with node.bcrypt.js, see #26
1 parent 7f3c443 commit f895e1f

5 files changed

Lines changed: 86 additions & 64 deletions

File tree

dist/bcrypt.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@
110110
* @expose
111111
*/
112112
bcrypt.genSaltSync = function(rounds, seed_length) {
113-
if (typeof rounds === 'undefined')
114-
rounds = GENSALT_DEFAULT_LOG2_ROUNDS;
115-
else if (typeof rounds !== 'number')
113+
rounds = rounds || GENSALT_DEFAULT_LOG2_ROUNDS;
114+
if (typeof rounds !== 'number')
116115
throw Error("Illegal arguments: "+(typeof rounds)+", "+(typeof seed_length));
117-
if (rounds < 4 || rounds > 31)
118-
throw Error("Illegal number of rounds (4-31): "+rounds);
116+
if (rounds < 4)
117+
rounds = 4;
118+
else if (rounds > 31)
119+
rounds = 31;
119120
var salt = [];
120121
salt.push("$2a$");
121122
if (rounds < 10)

0 commit comments

Comments
 (0)