Web Crypto
subtle.digest()
Computes a digest of a complete buffer. An unkeyed digest alone does not authenticate a sender; use a MAC or signature for that. Tested on Node.js 22.16.0. Example output (one line per entry): ["ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"].
Formal Syntax & Structure
nodejs syntaxnodejs
subtle.digest(algorithm, data)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| algorithm | string | object | Digest algorithm. |
| data | BufferSource | Message bytes. |
Return Value
Promise<ArrayBuffer>
Digest bytes.
Working Example
Example Snippetnodejs
import { webcrypto as crypto } from 'node:crypto';const hash = await crypto.subtle.digest('SHA-256', new TextEncoder().encode('abc'));console.log(Buffer.from(hash).toString('hex'));