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.
| API | Supported? | Notes |
|---|---|---|
| Certificate ↗ | ✅ | |
| Cipher ↗ | ||
| Decipher ↗ | ||
| DiffieHellman ↗ | ✅ | |
| DiffieHellmanGroup ↗ | ✅ | |
| ECDH ↗ | ||
| Hash ↗ | ✅ | |
| Hmac ↗ | ✅ | |
| KeyObject ↗ | ✅ | |
| Sign ↗ | ||
| Verify ↗ | ||
| X509Certificate ↗ | ✅ | |
| constants ↗ |
| API | Supported? | Notes |
|---|---|---|
| checkPrime ↗ | ✅ | |
| checkPrimeSync ↗ | ✅ | |
| generatePrime ↗ | ✅ | |
| generatePrimeSync ↗ | ✅ |
| API | Supported? | Notes |
|---|---|---|
| createCipher ↗ | Deprecated, use createCipheriv instead | |
| createCipheriv ↗ | ||
| createDecipher ↗ | Deprecated, use createDecipheriv instead | |
| createDecipheriv ↗ | ||
| privateDecrypt ↗ | ||
| privateEncrypt ↗ | ||
| publicDecrypt ↗ | ||
| publicEncrypt ↗ |
| API | Supported? | Notes |
|---|---|---|
| createDiffieHellman(prime) ↗ | ✅ | |
| createDiffieHellman(primeLength) ↗ | ✅ | |
| createDiffieHellmanGroup ↗ | ✅ | |
| createECDH ↗ | ||
| diffieHellman ↗ | ||
| getDiffieHellman ↗ | ✅ |
| API | Supported? | Notes |
|---|---|---|
| createHash ↗ | ✅ | |
| createHmac ↗ | ✅ | |
| getHashes ↗ | ✅ |
| API | Supported? | Notes |
|---|---|---|
| createPrivateKey ↗ | ✅ | |
| createPublicKey ↗ | ✅ | |
| createSecretKey ↗ | ✅ | |
| generateKey ↗ | ✅ | |
| generateKeyPair ↗ | ✅ | Does not support DSA or DH key pairs |
| generateKeyPairSync ↗ | ✅ | Does not support DSA or DH key pairs |
| generateKeySync ↗ | ✅ |
| API | Supported? | Notes |
|---|---|---|
| createSign ↗ | ||
| createVerify ↗ | ||
| sign ↗ | ||
| verify ↗ |
| API | Supported? | Notes |
|---|---|---|
| getCipherInfo ↗ | ||
| getCiphers ↗ | ✅ | |
| getCurves ↗ | ✅ | |
| secureHeapUsed ↗ | ✅ | |
| setEngine ↗ | ✅ | |
| timingSafeEqual ↗ | ✅ |
| API | Supported? | Notes |
|---|---|---|
| getFips ↗ | ✅ | |
| fips ↗ | ✅ | Deprecated, use getFips() instead |
| setFips ↗ | ✅ |
| API | Supported? | Notes |
|---|---|---|
| getRandomValues ↗ | ✅ | |
| randomBytes ↗ | ✅ | |
| randomFillSync ↗ | ✅ | |
| randomFill ↗ | ✅ | |
| randomInt ↗ | ✅ | |
| randomUUID ↗ | ✅ |
| API | Supported? | Notes |
|---|---|---|
| hkdf ↗ | ✅ | Does not yet support KeyObject |
| hkdfSync ↗ | ✅ | Does not yet support KeyObject |
| pbkdf2 ↗ | ✅ | |
| pbkdf2Sync ↗ | ✅ | |
| scrypt ↗ | ✅ | |
| scryptSync ↗ | ✅ |
| API | Supported? | Notes |
|---|---|---|
| subtle ↗ | ✅ | |
| webcrypto ↗ | ✅ |