Am I doing something wrong: asmcrypto way slower than other libs with sha256
See original GitHub issueHi.
I made a little benchmark to compare asmcrypto with two other popular node.js crypto libs and my tests show that it’s way slower than them, which is unexpected considering that performance is the main point of your lib:
let asm = require('asmcrypto.js');
start = process.hrtime();
for (let i = 0; i < 100000; i++) {
asm.SHA256
.hex('abcdefghijklmnopqrstuvwxyz')
;
}
diff = process.hrtime(start);
console.log((diff[0] * 1e9 + diff[1]) / 1e6 + 'ms');
let shajs = require('sha.js');
start = process.hrtime();
for (let i = 0; i < 100000; i++) {
shajs('sha256')
.update('abcdefghijklmnopqrstuvwxyz')
.digest('hex')
;
}
diff = process.hrtime(start);
console.log((diff[0] * 1e9 + diff[1]) / 1e6 + 'ms');
let crypto = require('crypto');
start = process.hrtime();
for (let i = 0; i < 100000; i++) {
crypto
.createHmac('sha256', '')
.update('abcdefghijklmnopqrstuvwxyz')
.digest('hex')
;
}
diff = process.hrtime(start);
console.log((diff[0] * 1e9 + diff[1]) / 1e6 + 'ms');
On my system:
asmcrypto: ~650ms sha.js: ~370ms crypto: ~300ms
Is there something I’m doing wrong here? I’m already thinkng that other crypto libs are extremely slow (for comparison, PHP hash function execute that test in ~70ms - yes, seventy!) and was hoping asmcrypto would solve that issue.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Why SHA-256 (or any other) is too fast for passwords but "slow ...
Since SHA-256 is much faster than dedicated password hashing functions, you can test guesses for colliding pairs much faster than you could ......
Read more >Create SHA-256 hash from a Blob/File in javascript
From what I've found, CryptoJS is the only one that supports hashing an ArrayBuffer directly, which is way faster than going through base-64,...
Read more >CryptoKit: SHA256 much much slower than `CryptoSwift`
Hey, CryptoKit's SHA256 (using it twice), is 3 times slower than CryptoSwift's implementation. I was hoping it would be the other way around....
Read more >Performance worse than sjcl lib · Issue #18 - GitHub
Since iojs v3 and node v4, Buffer is a subclass of Uint8Array . So .buffer should work just fine!
Read more >Why does Scrypt run so much slower than sha256? - Reddit
Before I start I am aware this is a question related to cryptocurrency but the question itself is regarding hashing algorithms so I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ericmorand : asmcrypto is asm.js / WebCrypto is binary. So on server side any binary implementation will beat asmcrypto.
Ooooh, sorry, I missed that part. Thanks for your clarification and patience.