Node.js API compatibility - Crypto
Explore the integration and utilization of the Node.js Crypto API within the Azion Runtime. The Crypto module in Node.js provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions.
The crypto API in Node.js provides a set of cryptographic functionalities to help developers secure their applications. It includes methods for hashing, encryption, decryption, and generating secure random values. This module is available in the Azion Runtime through Node.js compatibility, so you can use it inside functions to sign requests, verify message integrity, or generate unique identifiers close to your users.
Example: HMAC and UUID generation
The example below shows how to use the crypto module to generate HMAC signatures and UUIDs:
Example: Hash generation with SHA-256
Use hashing to verify data integrity or create deterministic identifiers:
Example: Random bytes generation
Generate cryptographically secure random values for tokens, session IDs, or nonces:
Example: Web Crypto API integration
The crypto module also provides access to the Web Crypto API through crypto.subtle. Note that crypto.subtle is equivalent to globalThis.crypto.subtle:
Supported APIs
| API | Status |
|---|---|
constants | 🟢 Supported |
createHash | 🟢 Supported |
createHmac | 🟢 Supported |
getRandomValues | 🟢 Supported |
randomBytes | 🟢 Supported |
randomUUID | 🟢 Supported |
subtle | 🟢 Supported |
webcrypto | 🟢 Supported |
createCipher | 🟡 Partially supported |
createDecipher | 🟡 Partially supported |
createSign | 🟡 Partially supported |
createVerify | 🟡 Partially supported |