In Python, one can generate random numbers in a number of ways. For example, one can use the random module to generate pseudorandom numbers in Python.
import random # Generate a random number in the range [2, 10] n = random.randint(2, 10) print(n) # Generate a random number in the range [2, 11) m = random.randrange(2, 11) print(m)
But, as per the Python documentation, pseudo-random generators of the random module should not be used for cryptographic purposes. Pseudo-random numbers generated using the random module is not secure enough.
How should we generate cryptographically secure random numbers in Python? There are a number of ways. In this article, we would discuss that in detail.
0 Comments