Web Crypto·续
Parameters
algorithmobject- Describes the algorithm to be used, including any required parameters, in an algorithm-specific format ↗︎.
baseKeyCryptoKeylengthint- Length of the bit string to derive.
importKey
importKey(format, keyData, algorithm, extractable, keyUsages): Promise\<CryptoKey>- Transform a key from some external, portable format into a
CryptoKeyfor use with the Web Crypto API.
Parameters
formatstring- Describes the format of the key to be imported ↗︎.
keyDataArrayBufferalgorithmobject- Describes the algorithm to be used, including any required parameters, in an algorithm-specific format ↗︎.
extractableboolkeyUsagesArray- An Array of strings indicating the possible usages of the new key ↗︎
exportKey
exportKey(formatstring, keyCryptoKey): Promise\<ArrayBuffer>- Transform a
CryptoKeyinto a portable format, if theCryptoKeyisextractable.
Parameters
formatstring- Describes the format in which the key will be exported ↗︎.
keyCryptoKey
wrapKey
wrapKey(format, key, wrappingKey, wrapAlgo): Promise\<ArrayBuffer>- Transform a
CryptoKeyinto a portable format, and then encrypt it with another key. This renders theCryptoKeysuitable for storage or transmission in untrusted environments.
Parameters
formatstring- Describes the format in which the key will be exported ↗︎ before being encrypted.
keyCryptoKeywrappingKeyCryptoKeywrapAlgoobject- Describes the algorithm to be used to encrypt the exported key, including any required parameters, in an algorithm-specific format ↗︎.
unwrapKey
unwrapKey(format, key, unwrappingKey, unwrapAlgo, unwrappedKeyAlgo, extractable, keyUsages): Promise\<CryptoKey>- Transform a key that was wrapped by
wrapKey()back into aCryptoKey.
Parameters
formatstring- Described the data format of the key to be unwrapped ↗︎.
keyCryptoKeyunwrappingKeyCryptoKeyunwrapAlgoobject- Describes the algorithm that was used to encrypt the wrapped key, in an algorithm-specific format ↗︎.
unwrappedKeyAlgoobject- Describes the key to be unwrapped, in an algorithm-specific format ↗︎.
extractableboolkeyUsagesArray- An Array of strings indicating the possible usages of the new key ↗︎
timingSafeEqual
timingSafeEqual(a, b): bool- Compare two buffers in a way that is resistant to timing attacks. This is a non-standard extension to the Web Crypto API.
Parameters
aArrayBuffer | TypedArraybArrayBuffer | TypedArray
Supported algorithms
Workers implements all operations of the WebCrypto standard ↗︎, as shown in the following table.
A checkmark (✓) indicates that this feature is believed to be fully supported according to the spec.
An x (✘) indicates that this feature is part of the specification but not implemented.
If a feature only implements the operation partially, details are listed.
| Algorithm | sign()<br>verify() | encrypt()<br>decrypt() | digest() | deriveBits()<br>deriveKey() | generateKey() | wrapKey()<br>unwrapKey() | exportKey() | importKey() |
|---|---|---|---|---|---|---|---|---|
| RSASSA PKCS1 v1.5 | ✓ | ✓ | ✓ | ✓ | ||||
| RSA PSS | ✓ | ✓ | ✓ | ✓ | ||||
| RSA OAEP | ✓ | ✓ | ✓ | ✓ | ✓ | |||
| ECDSA | ✓ | ✓ | ✓ | ✓ | ||||
| ECDH | ✓ | ✓ | ✓ | ✓ | ||||
| Ed25519<sup>1</sup> | ✓ | ✓ | ✓ | ✓ | ||||
| X25519<sup>1</sup> | ✓ | ✓ | ✓ | ✓ | ||||
| NODE ED25519<sup>2</sup> | ✓ | ✓ | ✓ | ✓ | ||||
| AES CTR | ✓ | ✓ | ✓ | ✓ | ✓ | |||
| AES CBC | ✓ | ✓ | ✓ | ✓ | ✓ | |||
| AES GCM | ✓ | ✓ | ✓ | ✓ | ✓ | |||
| AES KW | ✓ | ✓ | ✓ | ✓ | ||||
| HMAC | ✓ | ✓ | ✓ | ✓ | ||||
| SHA 1 | ✓ | |||||||
| SHA 256 | ✓ | |||||||
| SHA 384 | ✓ | |||||||
| SHA 512 | ✓ | |||||||
| MD5<sup>3</sup> | ✓ | |||||||
| HKDF | ✓ | ✓ | ||||||
| PBKDF2 | ✓ | ✓ |
Footnotes:
- Algorithms as specified in the Secure Curves API ↗︎.
- Legacy non-standard EdDSA is supported for the Ed25519 curve in addition to the Secure Curves version. Since this algorithm is non-standard, note the following while using it:
- Use
NODE-ED25519as the algorithm andnamedCurveparameters. - Unlike NodeJS, Cloudflare will not support raw import of private keys.
- The algorithm implementation may change over time. While Cloudflare cannot guarantee it at this time, Cloudflare will strive to maintain backward compatibility and compatibility with NodeJS's behavior. Any notable compatibility notes will be communicated in release notes and via this developer documentation.
- MD5 is not part of the WebCrypto standard but is supported in Cloudflare Workers for interacting with legacy systems that require MD5. MD5 is considered a weak algorithm. Do not rely upon MD5 for security.
Modern algorithms
The webcrypto_modern_algorithms compatibility flag enables a subset of the evolving Modern Algorithms in the Web Cryptography API ↗︎ draft.
| Algorithm | sign()<br>verify() | encapsulateKey()<br>encapsulateBits()<br>decapsulateKey()<br>decapsulateBits() | generateKey() | exportKey() | importKey() |
|---|---|---|---|---|---|
| ML-DSA-44, ML-DSA-65, and ML-DSA-87 | ✓ | ✓ | ✓ | ✓ | |
| ML-KEM-768 and ML-KEM-1024 | ✓ | ✓ | ✓ | ✓ | |
| ML-KEM-512 | ✘ | ✘ | ✘ | ✘ |
The flag also adds getPublicKey() and SubtleCrypto.supports(). It supports JSON Web Keys (JWKs) with the AKP key type.
Workers does not implement other algorithms from the draft. This API may change as the draft evolves.
Related resources
- SubtleCrypto documentation on MDN ↗︎
- SubtleCrypto documentation as part of the W3C Web Crypto API specification ↗︎
- Example: signing requests
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#page","headline":"Web Crypto","description":"A set of low-level functions for common cryptographic tasks.","url":"https://developers.cloudflare.com/workers/runtime-apis/web-crypto/","inLanguage":"en","image":"https://developers.cloudflare.com/workers/runtime-apis/web-crypto/og.png?v=6ad0cbc1a2ead550","dateModified":"2026-09-30","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Standardized APIs for use by Workers running on Cloudflare's global network. title: Web standards image: https://developers.cloudflare.com/workers/runtime-apis/web-standards/og.png?v=be37c9dac9250fd5
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt
Use this file to discover all available pages before exploring further.
Docs