crypto.timingSafeEqual()

A node:crypto function that compares two Buffers of equal length in a time that does not depend on where they differ.

In more detail

Use it to check HMAC signatures and tokens so the comparison leaks nothing through timing. It throws if the lengths differ, so compare the lengths first.

Related terms

Taught in

References