Search code examples
pythonrandomcryptographyentropy

Relation between random module's randomness and a supplied seed


So I am trying to get a cryptographically strong random number generator... The thing is, for certain reasons, I would still like to be able to assign a random seed to the generator (it can be a relatively large seed if necessary though).

So in light of this... If one uses a cryptographically strong random generator (like pycrypto's random module, or random.SystemRandom) to generate a random seed for the regular python random module, will the random module have sufficient randomness and entropy to be considered cryptographically strong?


Solution

  • If one uses a cryptographically strong random generator (like pycrypto's random module, or random.SystemRandom) to generate a random seed for the regular python random module, will the random module have sufficient randomness and entropy to be considered cryptographically strong?

    No. Whatever seed you use won't make the default Pseudo Random Number Generator (random.Random) into Cryptographically Strong Pseudo Random Number Generator (random.SystemRandom). See PEP 0506 -- Adding A Secrets Module To The Standard Library.