juanelas / scrypt-pbkdf Goto Github PK
View Code? Open in Web Editor NEWA faster JS implementation of the scrypt password-based key derivation function
License: MIT License
A faster JS implementation of the scrypt password-based key derivation function
License: MIT License
Hi,
I was looking for a replacement of https://docs.ethers.io/v5/concepts/security/#security--pbkdf . Because it is too slow for react-native. My knowledge on cryptography is limited. So in your examples I can see how to encrypt. But do you have an example on how to de-crypt and get the original values.
Regards,
Mariano
It appears the library is actually around 25% slower than scrypt-js
when the polifill for setImmediate
is provided (otherwise it fallbacks to setTimeout
which is slower due to being run in the tasks queue not micro tasks queue).
Input: {"P":"pleaseletmein","S":"SodiumChloride","N":65536,"r":8,"p":1,"dkLen":64}
scrypt-pbkdf — mean time: 626ms ±1.84% (9 runs sampled)
scrypt-js — mean time: 485ms ±3.34% (9 runs sampled)
scryptsy — mean time: 23649ms ±267.28% (8 runs sampled)
Input: {"P":"pleaseletmein","S":"SodiumChloride","N":131072,"r":8,"p":1,"dkLen":64}
scrypt-pbkdf — mean time: 1292ms ±4.10% (7 runs sampled)
scrypt-js — mean time: 946ms ±2.58% (9 runs sampled)
scryptsy — mean time: 10943ms ±186.85% (6 runs sampled)
Input: {"P":"pleaseletmein","S":"SodiumChloride","N":262144,"r":8,"p":1,"dkLen":64}
scrypt-pbkdf — mean time: 2529ms ±1.60% (6 runs sampled)
scrypt-js — mean time: 1888ms ±1.64% (7 runs sampled)
scryptsy — mean time: 5179ms ±0.14% (5 runs sampled)
Hi! this gist (another implementationt of scrypt also based on Web Crypto) seems to be REALLY noticeably faster when running in chromium derived versions (tried on Google Chrome and Iron Browser).
Also tried in Firefox but it doesn't work due to this bug (yet more info here) . Happily it can be easily fixed using this lib also by juanelas. Once applied the fix, the speed is much similar to scrypt-pbkdf but still slighty faster.
Haven't tried with other browsers and I do not know whether the implementation is correct or not. I am not the developer of the gist and frankly the math behind cryptographic algorithms I don't think is my thing so I can't say.
But I think it's worth it to @juanelas to take a look.
Hope it helps! (And thanks for your work!)
Similar to scrypt js, progress callback support and non-blocking behavior, perhaps via webworker.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.