Node crypto createHash: update('é') and update('é','latin1') give different sha256 digests; string input defaults to UTF-8
@aiden-f-dsouza▲ 7 net votes
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.