Two issues: 1) Why would you expect it to be faster? It's pure JS using
asm.js (which Node doesn't support), vs bcrypt is compiled C code. And 2)
Being slow is a feature of bcrypt - it makes brute force cracking harder.

On Wed, Sep 10, 2014 at 10:54 AM, Adrian Lynch <
[email protected]> wrote:

> I'm seeing bcryptjs beat twin every time with the following code:
>
> var bcryptJS = require('bcryptjs');
> var twinBcrypt = require('twin-bcrypt');
>
> var password = "password";
> var rounds = 12;
> var hash, start, end;
>
> // twin-bcrypt
> start = new Date();
> hash = twinBcrypt.hashSync(password, twinBcrypt.genSalt(rounds));
> end = new Date();
> console.log("Took \t" + (end - start) + "ms\t to hash '" + password + "'
> into '" + hash + "'");
>
> // bcryptjs
> start = new Date();
> hash = bcryptJS.hashSync(password, bcryptJS.genSaltSync(rounds));
> end = new Date();
> console.log("Took \t" + (end - start) + "ms\t to hash '" + password + "'
> into '" + hash + "'");
>
> On my Mac, BJS comes in at ~950ms and twim, ~1700ms.
>
> From the description of twin-bcrypt, I'd expect it to be quicker.
>
> Does my test code look OK? Am I mis-using the libs?
>
> Thanks.
>
> Adrian
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/CAH368SSHMxGhSWepY5bOETSdkW8uY76b%3D8FFm6Tk6yt2aKWVRQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/nodejs/CAH368SSHMxGhSWepY5bOETSdkW8uY76b%3D8FFm6Tk6yt2aKWVRQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAPJ5V2ZnpqBYb%3DgNU2pCeo1BnBiG2r5kx6sBVbb5kRZw3FSF0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to