robinmoisson / staticrypt

Password protect a static HTML page, decrypted in-browser in JS with no dependency. No server logic needed.
https://robinmoisson.github.io/staticrypt/
MIT License
7.1k stars 431 forks source link

Support for WebCrypto in 2.x #164

Closed robinmoisson closed 1 year ago

robinmoisson commented 1 year ago

This brings support for webcrypto and switching from cryptojs to webcrypto implementation. Switching to WebCrypto should be :

This is heavily inspired by #139 (thank you very much for that PR @hurrymaplelad , it has been very useful!), and edited for backward compatibility. The PR also detects which password_template version the user is running, and tries to nudge them towards using WebCrypto.

Trying to make everything as backward compatible as possible makes the code sort of a mess and hard to reason about, but I wanted to put out something that could use WebCrypto in version 2.x so people can be nudged towards it. This will be the last update in 2.x appart from bugfixes, next will be a lot of clean up working towards 3.x, where I have a few nice ideas for improvement.

Anyone can feel free to review this and comment, especially the webcryptoEngine.js part. I'll do some more tests and merge in a short while.