Cloudflare 中文文档
Workers
Workers
编辑这个页面
跳转官方原文档
Set theme to dark (⇧+D)

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

API Supported? Notes
Certificate
Cipher
Decipher
DiffieHellman
DiffieHellmanGroup
ECDH
Hash
Hmac
KeyObject
Sign
Verify
X509Certificate
constants

​​ Primes

API Supported? Notes
checkPrime
checkPrimeSync
generatePrime
generatePrimeSync

​​ Ciphers

API Supported? Notes
createCipher Deprecated, use createCipheriv instead
createCipheriv
createDecipher Deprecated, use createDecipheriv instead
createDecipheriv
privateDecrypt
privateEncrypt
publicDecrypt
publicEncrypt

​​ DiffieHellman

API Supported? Notes
createDiffieHellman(prime)
createDiffieHellman(primeLength)
createDiffieHellmanGroup
createECDH
diffieHellman
getDiffieHellman

​​ Hash

API Supported? Notes
createHash
createHmac
getHashes

​​ Keys

API Supported? Notes
createPrivateKey
createPublicKey
createSecretKey
generateKey
generateKeyPair
generateKeyPairSync
generateKeySync

​​ Sign/Verify

API Supported? Notes
createSign
createVerify
sign
verify

​​ Misc

API Supported? Notes
getCipherInfo
getCiphers
getCurves
secureHeapUsed
setEngine
timingSafeEqual

​​ Fips

API Supported? Notes
getFips
fips Deprecated, use getFips() instead
setFips

​​ Random

API Supported? Notes
getRandomValues
randomBytes
randomFillSync
randomFill
randomInt
randomUUID

​​ Key Derivation

API Supported? Notes
hkdf Does not yet support KeyObject
hkdfSync Does not yet support KeyObject
pbkdf2
pbkdf2Sync
scrypt
scryptSync

​​ WebCrypto

API Supported? Notes
subtle
webcrypto