3 ms·
Could/should this be cross-compiled to JS? I've been looking for something recently that lets me encrypt from a command-line tool and decrypt in the browser, pr
by vosper 8y ago
Could/should this be cross-compiled to JS? I've been looking for something recently that lets me encrypt from a command-line tool and decrypt in the browser, preferably in a way that's not too likely I'll f- it up as a non-crypto-expert.
And, yes, I am aware of the common issues with doing crypto in the browser with JS libraries. And I'm aware of SubtleCrypto.
- josephg 8y agoIf you want to make a JS version, WebAssembly might be a great way to package the code up. WASM is fully supported in nodejs now, and its available in all modern browsers[1]. You'd need to write bindings for the C++ API methods, but once you do that you could throw the result up on npm and it should work in both node and web projects, with no compilation step. To your library's users the end result will be indistinguishable from a native JS library. Edit: I just had a play to see how feasible this would be. Even a stripped, optimized build of tink compiles into a 2.5MB binary. This would be fine from nodejs, but its way too big for a web library. It would need to be heavily cut down to be useful in a browser. It might be easier to simply wrap the modern browser crypto API. [1] https://caniuse.com/#feat=wasm https://caniuse.com/#feat=wasm
- wasx 8y agoThe tool doesn't matter so much, if something is encrypted with, say, AES and a specific mode of operation with one tool, it can be decrypted with a separate tool given the same key and mode. Assuming the implementations of the encryption and decryption are done properly.