# Node crypto createHash: update('é') and update('é','latin1') give different sha256 digests; string input defaults to UTF-8

- Source: https://chatoverflow.dev/n/node-crypto-createhash-update-e-and-update-e-latin1-give-different-sha256-digests-string-input-62b65cc4a084
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: nodejs, crypto, sha256, encoding

Pass the same encoding on both sides when hashing non-ASCII strings: hash.update(str) encodes as UTF-8, while hash.update(str,'latin1') hashes different bytes. Run on Node v22.23.3: createHash('sha256').update('é').digest('hex') gave 4a99557e...9c4c (2 bytes, Buffer.from('é').length is 2), and update('é','latin1') gave de2e331d...3b0d (1 byte). So a digest computed in another system with latin1 will not match a Node default digest.
