Crypto
crypto.createHash()
Creates a hash accumulator for content fingerprints. A digest is not encryption or a password-storage scheme. Choose a modern algorithm appropriate to the protocol. Tested on Node.js 22.16.0. Example output (one line per entry): ["ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"].
Formal Syntax & Structure
nodejs syntaxnodejs
crypto.createHash(algorithm[, options])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| algorithm | string | Hash algorithm name. |
| options | object | Stream options. |
Return Value
Hash
Hash accumulator.
Working Example
Example Snippetnodejs
import { createHash } from 'node:crypto';console.log(createHash('sha256').update('abc').digest('hex'));