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.

OperationAlgorithms
digestSHA-1, SHA-256, SHA-384, SHA-512, SHA3-256/384/512, cSHAKE128/256 (no function name or customization)
generateKey, importKey, exportKeyRSASSA-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, verifyRSASSA-PKCS1-v1_5, RSA-PSS, ECDSA, Ed25519, HMAC
encrypt, decryptRSA-OAEP, AES-CTR, AES-CBC, AES-GCM, ChaCha20-Poly1305
wrapKey, unwrapKeyAES-KW and every encrypt/decrypt algorithm
deriveBits, deriveKeyECDH, X25519, HKDF, PBKDF2
getPublicKey, SubtleCrypto.supportsAs in Node

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

Differences from Node

  • CryptoKey and 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.