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
| Name | Type | Description |
|---|---|---|
| data | string | Buffer | TypedArray | DataView | Input bytes. |
| inputEncoding | string | Encoding 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);