Skip to main content

crypto

Note

For compatibility dates of 2026-08-04 or later, Workers enables both nodejs_compat and nodejs_compat_v2 by default. These flags are not used for these compatibility dates. Existing projects do not need to remove them when updating their compatibility date. For earlier dates, add nodejs_compat to your Wrangler configuration file to opt in. For instructions to turn off Node.js compatibility, refer to the Node.js compatibility flag.

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

All node:crypto APIs are fully supported in Workers with the following exceptions:

  • The functions generateKeyPair and generateKeyPairSync do not support DSA or DH key pairs.
  • argon2 and argon2Sync are not supported.
  • ed448 and x448 curves are not supported.
  • It is not possible to manually enable or disable FIPS mode.

The full node:crypto API is documented in the Node.js documentation for node:crypto.

The WebCrypto API is also available within Cloudflare Workers. This does not require the nodejs_compat compatibility flag.