dcodeIO / bcrypt.js

Optimized bcrypt in plain JavaScript with zero dependencies.
Other
3.47k stars 264 forks source link

hashSync method cost too long time #125

Open CurrrryChen opened 3 years ago

CurrrryChen commented 3 years ago

code as below:

const bcrypt = require('bcryptjs');

console.time();
const salt = bcrypt.genSaltSync(20);
const hash = bcrypt.hashSync('I love cupcakes', salt);
console.timeEnd();

console.log(hash);

log as below:

default: 1:26.472 (m:ss.mmm)
$2a$20$oO4XV.2/F4sq9LYCtBtedel65ntZLJCYq70PPAZ0bEoNsPo.i.LCa

MacOS: 10.15.7 Node: v14.16.0

Everthing goes well weeks ago,I tried to restart my pc and reinstall node and clear node_modules, nothing changed.

sashankaryal commented 3 years ago

With 20 salt rounds, I'm not surprised.

rounds=8 : ~40 hashes/sec rounds=9 : ~20 hashes/sec rounds=10: ~10 hashes/sec rounds=11: ~5 hashes/sec rounds=12: 2-3 hashes/sec rounds=13: ~1 sec/hash rounds=14: ~1.5 sec/hash rounds=15: ~3 sec/hash rounds=25: ~1 hour/hash rounds=31: 2-3 days/hash