node:crypto API Reference

Hashing, HMAC, key derivation, and random-data helpers

import { createHash, randomUUID } from "node:crypto";

console.log(createHash("sha256").update("abc").digest("hex"));
console.log(randomUUID());

Supported surface

  • createHash and createHmac
  • randomBytes, randomFill, randomFillSync, randomInt, and randomUUID
  • pbkdf2, pbkdf2Sync, scrypt, and scryptSync
  • timingSafeEqual, getHashes, getCiphers, constants, and webcrypto

Hash names reported by getHashes() are sha1, SHA-2, SHA-3, and md5 variants. In Elide 1.5.0, getCiphers() is empty. The webcrypto export is the same object as globalThis.crypto.

Hash and HMAC inputs may be strings, buffers, array buffers, data views, or typed arrays. digest() returns a Buffer without an encoding, or a string for encodings such as hex, base64, and base64url.

In Elide 1.5.0, the callback forms perform their computation eagerly before delivering the result. scrypt is available, but derived key lengths below 16 bytes fail even though Node permits smaller values.

Ciphers, signing, key-pair generation, and Diffie-Hellman APIs are not exposed by this module in Elide 1.5.0.

See the Node.js crypto documentation for standard argument forms.