Cover

Random or Secrets which module to use for critical information?

It’s easy to generate random numbers using the random module in Python. And we always do it when it’s required to send an OTP or a secret token to the user. The following code is the way we do it usually. import random random.randint(100000, 999999) This should generate a 6 digit random OTP code. But, according to the offical documentation of python secrets module, it’s not recommended to use the random module for generating passwords, account authentication, security tokens and related secrets....

January 24, 2023 · 2 min · Nazrul