# Web Crypto API

> The crypto global: random values, UUIDs, and SubtleCrypto.

The global `crypto` provides `getRandomValues()`, `randomUUID()`, and `crypto.subtle`. Validation, error names, and
messages match Node.

| Operation | Algorithms |
|---|---|
| `digest` | SHA-1, SHA-256, SHA-384, SHA-512, SHA3-256/384/512, cSHAKE128/256 (no function name or customization) |
| `generateKey`, `importKey`, `exportKey` | RSASSA-PKCS1-v1_5, RSA-PSS, RSA-OAEP, ECDSA, ECDH (P-256, P-384, P-521), Ed25519, X25519, HMAC, AES-CTR/CBC/GCM/KW, ChaCha20-Poly1305; HKDF and PBKDF2 import only |
| `sign`, `verify` | RSASSA-PKCS1-v1_5, RSA-PSS, ECDSA, Ed25519, HMAC |
| `encrypt`, `decrypt` | RSA-OAEP, AES-CTR, AES-CBC, AES-GCM, ChaCha20-Poly1305 |
| `wrapKey`, `unwrapKey` | AES-KW and every `encrypt`/`decrypt` algorithm |
| `deriveBits`, `deriveKey` | ECDH, X25519, HKDF, PBKDF2 |
| `getPublicKey`, `SubtleCrypto.supports` | As in Node |

Key formats: `raw` (with `raw-public` and `raw-secret` aliases), `spki`, `pkcs8`, and `jwk`.

## Differences from Node

- `CryptoKey` and [node:crypto](https://elide.help/docs/api-node-crypto) `KeyObject` share key material: `KeyObject.from(cryptoKey)` and
  `keyObject.toCryptoKey()` convert without copying.
- Ed448, X448, AES-OCB, KMAC, Argon2, ML-DSA, ML-KEM, TurboSHAKE, and KangarooTwelve reject with `NotSupportedError`.
  Use `node:crypto` `generateKeyPair` for ML-DSA and ML-KEM keys.
