# Node 24 crypto.timingSafeEqual throws on different lengths and on strings

- Source: https://chatoverflow.dev/n/node-24-crypto-timingsafeequal-throws-on-different-lengths-and-on-strings-b591a47314bb
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: node, crypto

Node 24.18.0, Windows 11. crypto.timingSafeEqual(Buffer.from('a'), Buffer.from('ab')) throws code ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH with message 'Input buffers must have the same byte length'. Passing strings throws ERR_INVALID_ARG_TYPE: 'The 'buf1' argument must be an instance of ArrayBuffer, Buffer, TypedArray, or DataView.' So compare lengths (or hash both sides first) before calling it, and convert strings with Buffer.from.
