3 ms·
SJCL is 6.4KB gzipped, libsodium is 188KB. If one plans to use the lib in the browser, it makes a huge difference. Also, I'm not a crypto expert by any mean,
by BiteCode_dev 6y ago
SJCL is 6.4KB gzipped, libsodium is 188KB.
If one plans to use the lib in the browser, it makes a huge difference.
Also, I'm not a crypto expert by any mean, but SJCL seems higher level, and hence, easier to use. Not to mention harder to missuse.
Projects like https://0bin.net https://0bin.net have been using it for 7 years, with 500000 visitors in the last few months, so I'd say it's pretty battle tested too.
Not nearly has much as libsodium, of course. But I wouldn't discard SJCL, I think it has a place.
- buu700 6y agoThat's a fair point, to some extent. If you're specifically looking to perform symmetric encryption on a string with a string-encoded password, then yes, SJCL is easier to use. The documentation is centered around that one simple example, and the library doesn't seem to do a lot else (at least through a high-level API). I also have a problem with NaCl/Sodium forcing users to handle nonces, rather than handling that detail internally by default. Besides that, Sodium isn't particularly more difficult to use than SJCL; the whole point is that it's an easy-to-use high-level interface that's hard to misuse. I would also note that SJCL's defaults are a bit dated (CCM vs GCM, 128-bit vs 256-bit, PBKDF2 vs a memory-hard KDF like scrypt or Argon2). Additionally, being pure JS would raise concerns about side channel attacks more so than WebAssembly (like libsodium.js) or native code (like WebCrypto). I'm sure there are simple use cases where SJCL provides some value, and I'm not saying data and applications that depend on it out in the wild should necessarily be considered already compromised, but I'd struggle to think of a situation where I would consider using it in a new project today, over either libsodium or nothing at all / just TLS.
- Thorrez 6y agoHow does it compare to https://tweetnacl.js.org https://tweetnacl.js.org ? That's 7KB minified and gzipped.
- BiteCode_dev 6y agoNever tried it
- buu700 6y agoTweetNaCl.js is great. I'd go with that if you really need something smaller than libsodium. Presumably it shares the downsides of TweetNaCl ("doesn't wipe internal buffers [...] [and] has two harmless instances of undefined behaviour"[1]; among, I expect, other shortcuts that may make it less optimal/safe than NaCl), and the fact that it's pure JS adds additional side channel attack surface, but those may be acceptable risks depending on your threat model. They're certainly the least of your concerns if you're just using it in a web page like 0bin.net. 1: https://monocypher.org/why https://monocypher.org/why