Node.js · Middle · Question 45 of 75

How should you compare a secret token from a request with the stored one?

Explanation

=== stops at the first different character, so response time can leak how much of the token was correct. A constant-time comparison avoids that.

Further reading

Problem with a question

Node.js · Middle · question 45

Test yourself

Take the Node.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz