Randomness and comparison that hold up

Lesson 14 of 27 · Secrets, crypto and data handling · 2 min Get the course to watch

Tidepool needs a password reset link. The assistant builds a token from the random module, because that is the random module everyone knows. The link looks random and works in every test. And it is a token someone can predict.

That is the pattern with security defaults in generated code. The wrong choice and the right choice behave identically in every test you will write, so only a reviewer who knows the difference can tell.

The rest of this lesson

  • Two kinds of random
  • Seeing the difference
  • The sound token
  • Compare secrets in constant time
  • Where this applies
  • What to keep

The full lesson is animated and narrated, with a short quiz, and you can pause it to ask a question. It comes with Secure the code AI writes.