diff --git a/src/bcrypt.js b/src/bcrypt.js index d9c0492..3abed94 100644 --- a/src/bcrypt.js +++ b/src/bcrypt.js @@ -75,14 +75,14 @@ bcrypt.genSaltSync = function(rounds, seed_length) { rounds = 4; else if (rounds > 31) rounds = 31; - var salt = []; - salt.push("$2a$"); + var salt = ''; + salt = salt.concat("$2a$"); if (rounds < 10) - salt.push("0"); - salt.push(rounds.toString()); - salt.push('$'); - salt.push(base64_encode(random(BCRYPT_SALT_LEN), BCRYPT_SALT_LEN)); // May throw - return salt.join(''); + salt = salt.concat("0"); + salt = salt.concat(rounds.toString()); + salt = salt.concat('$'); + salt = salt.concat(base64_encode(random(BCRYPT_SALT_LEN), BCRYPT_SALT_LEN)); // May throw + return salt; }; /** diff --git a/tests/suite.js b/tests/suite.js index 8c8afe1..0048b99 100644 --- a/tests/suite.js +++ b/tests/suite.js @@ -177,7 +177,7 @@ module.exports = { "roundsOOB": function(test) { var salt1 = bcrypt.genSaltSync(0), // $10$ like not set - salt2 = binding.genSaltSync(0); + salt2 = binding.genSaltSync(0, 'a'); test.strictEqual(salt1.substring(0, 7), "$2a$10$"); test.strictEqual(salt2.substring(0, 7), "$2a$10$");