Skip to content

Crypto

The node:crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL’s hash, HMAC, cipher, decipher, sign, and verify functions.

A subset of the node:crypto module is available in Workers. All APIs in the tables below with a ✅ are supported, and unless otherwise noted, work the same way as the implementations in Node.js.

The WebCrypto API is also available within Cloudflare Workers.

Classes

APISupported?Notes
Certificate ↗✅
Cipher ↗
Decipher ↗
DiffieHellman ↗✅
DiffieHellmanGroup ↗✅
ECDH ↗
Hash ↗✅
Hmac ↗✅
KeyObject ↗
Sign ↗
Verify ↗
X509Certificate ↗✅
constants ↗

Primes

APISupported?Notes
checkPrime ↗✅
checkPrimeSync ↗✅
generatePrime ↗✅
generatePrimeSync ↗✅

Ciphers

APISupported?Notes
createCipher ↗Deprecated, use createCipheriv instead
createCipheriv ↗
createDecipher ↗Deprecated, use createDecipheriv instead
createDecipheriv ↗
privateDecrypt ↗
privateEncrypt ↗
publicDecrypt ↗
publicEncrypt ↗

DiffieHellman

APISupported?Notes
createDiffieHellman(prime) ↗✅
createDiffieHellman(primeLength) ↗✅
createDiffieHellmanGroup ↗✅
createECDH ↗
diffieHellman ↗
getDiffieHellman ↗✅

Hash

APISupported?Notes
createHash ↗✅
createHmac ↗✅
getHashes ↗✅

Keys

APISupported?Notes
createPrivateKey ↗
createPublicKey ↗
createSecretKey ↗✅
generateKey ↗✅
generateKeyPair ↗✅
generateKeyPairSync ↗✅
generateKeySync ↗✅

Sign/Verify

APISupported?Notes
createSign ↗
createVerify ↗
sign ↗
verify ↗

Misc

APISupported?Notes
getCipherInfo ↗
getCiphers ↗✅
getCurves ↗✅
secureHeapUsed ↗✅
setEngine ↗✅
timingSafeEqual ↗✅

Fips

APISupported?Notes
getFips ↗✅
fips ↗✅Deprecated, use getFips() instead
setFips ↗✅

Random

APISupported?Notes
getRandomValues ↗✅
randomBytes ↗✅
randomFillSync ↗✅
randomFill ↗✅
randomInt ↗✅
randomUUID ↗✅

Key Derivation

APISupported?Notes
hkdf ↗✅Does not yet support KeyObject
hkdfSync ↗✅Does not yet support KeyObject
pbkdf2 ↗✅
pbkdf2Sync ↗✅
scrypt ↗✅
scryptSync ↗✅

WebCrypto

APISupported?Notes
subtle ↗✅
webcrypto ↗✅