# notepadsuite-crypto

This is the encryption code used by notepadsuite.com. It is about 100 lines of JavaScript. It runs only in the browser and uses the standard Web Cryptography API (`crypto.subtle`), so there are no other dependencies.

| Feature | How it is protected |
| --- | --- |
| Encrypted share links | A random 256-bit key and AES-GCM with a random 96-bit IV. The key lives only in the link, after `#k=` |
| Protected notes | PBKDF2-HMAC-SHA256 (600,000 iterations, 128-bit random salt) turns your password into 512 bits: an AES-GCM key and a write token |
| Password-protected clipboard items | The same PBKDF2 setup gives the AES-GCM key |

## Check it
```sh
node test.mjs      # Node 20+. Compares every result with Node's own OpenSSL-based crypto.
```
Compare this file with the copy that the site actually serves:
```sh
curl -s https://notepadsuite.com/assets/crypto.js | sha256sum
sha256sum crypto.js
```
The two hashes should match. The current hash is also published at https://notepadsuite.com/security/.

## Files
- `crypto.js`: the module, copied from `public/assets/crypto.js` on every site build.
- `test.mjs`: cross-checks against `node:crypto`.
- `LICENSE`: MIT.
