Back to the module table.
node:crypto is split between the page and the core, depending on what is cheaper per call:
crypto.getRandomValues.Nothing calls the core at import time.
| Area | API |
|---|---|
| Hashes | createHash, hash (one-shot), Hash.copy(), getHashes(): md5, sha1, sha224, sha256, sha384, sha512, sha512-224, sha512-256, sha3-224/256/384/512, shake128, shake256, ripemd160, blake2b512, blake2s256, and the RSA-*/*WithRSAEncryption aliases |
| HMAC | createHmac with any of the hashes above |
| Ciphers | createCipheriv, createDecipheriv, getCiphers(): aes-128/192/256 in cbc, ecb, ctr, cfb, cfb8, ofb and gcm; chacha20, chacha20-poly1305; des-ede3(-cbc), des-ede(-cbc), des(-cbc/-ecb). Also setAutoPadding, setAAD, getAuthTag and setAuthTag. |
| Keys | createPublicKey, createPrivateKey, createSecretKey, KeyObject (export as PEM, DER or JWK), generateKeyPair(Sync) for rsa, rsa-pss, ec, ed25519, ed448, x25519 and x448, generateKey(Sync) for hmac and aes |
| Signatures | createSign, createVerify, sign, verify: RSA PKCS#1 v1.5, RSA-PSS, ECDSA (DER or ieee-p1363), Ed25519, Ed448 |
| RSA | publicEncrypt, privateDecrypt, privateEncrypt, publicDecrypt |
| Key agreement | createDiffieHellman(prime \| length, generator), createDiffieHellmanGroup/getDiffieHellman (modp1, modp2, modp5, modp14 to modp18), createECDH on getCurves() (prime256v1, secp224r1, secp256k1, secp384r1, secp521r1), diffieHellman({ privateKey, publicKey }) for X25519, X448 and EC |
| KDFs | pbkdf2(Sync), scrypt(Sync), hkdf(Sync) |
| Random | randomBytes, randomFill(Sync), randomInt, randomUUID, getRandomValues |
| Misc | timingSafeEqual, constants, getFips() (always 0), setFips |
| Web Crypto | webcrypto and subtle are the webview’s crypto and crypto.subtle |
ssh2 runs every algorithm OpenSSH 10 accepts on this module in the webview, including curve25519-sha256, [email protected], diffie-hellman-group-exchange-* and every modp group (36 of 36 combinations that Node completes).
X509Certificate and Certificate throw. DSA and DH key generation (generateKeyPair("dsa" | "dh")) throws ERR_OSSL_UNSUPPORTED. There are no engine or secure heap APIs.
Error objects carry Node’s code (ERR_CRYPTO_INVALID_KEYLEN, ERR_OSSL_BAD_DECRYPT, …) where the conformance suite checks them, but not OpenSSL’s library, reason or opensslErrorStack.
node:zlib from Node 24 over Go’s compress/flate (via klauspost) and andybalholm/brotli:
deflateSync, gunzipSync, brotliCompressSync, …) are one sync core call.deflate, gzip, …) are one async call, so the compression runs off the page’s thread.createGzip(), createInflate(), createBrotliDecompress(), …) are stream.Transforms, with one async call per chunk.crc32(data, initial?) runs in TypeScript.The classes (Deflate, Inflate, Gzip, Gunzip, DeflateRaw, InflateRaw, Unzip, BrotliCompress, BrotliDecompress) are function constructors as in Node. constants, codes, info: true and maxOutputLength are supported.
zstdCompress, createZstdCompress, …). It will be added when a consumer needs it.Z_FILTERED, Z_RLE, Z_FIXED and memLevel are accepted and compress like the defaults. A windowBits below 15 compresses with Huffman coding only. Z_FULL_FLUSH flushes like Z_SYNC_FLUSH (the match window is kept). The brotli mode and size hint are ignored.code and errno are zlib’s.chunkSize slicing.