Crypto

hash.update()

Feeds bytes into an existing digest. Chunk boundaries do not change the digest if the concatenated bytes are identical. Encode text consistently before comparing fingerprints. Tested on Node.js 22.16.0. Example output (one line per entry): ["true"].

Formal Syntax & Structure

nodejs syntaxnodejs
hash.update(data[, inputEncoding])

Parameters & Attributes

NameTypeDescription
datastring | Buffer | TypedArray | DataViewInput bytes.
inputEncodingstringEncoding for string input.

Return Value

Hash

Same accumulator.

Working Example

Example Snippetnodejs
import { createHash } from 'node:crypto';const a = createHash('sha256').update('book').update('store').digest('hex');const b = createHash('sha256').update('bookstore').digest('hex');console.log(a === b);
Node.js Reference