Skip to content
Advertisement

Seedable CSPRNG for python?

With the random module, you are able to seed it to get the same values every time.

JavaScript

Is there a CSPRNG that can do this? For example, according to this question How can I create a random number that is cryptographically secure in python?, random.SystemRandom is secure. But seeding it doesn’t return the same thing.

JavaScript

Does such a CSPRNG exist? or does this negate the security aspect?

Advertisement

Answer

The randomgen package provides NumPy compatible CSPRNGs, e.g. ChaCha which can be used as:

JavaScript

Notes:

  • I’m using a reduced round variant, 20 rounds is more normal but 8 seems to be enough for most purposes
  • randomgen provides its own Generator, but it’s deprecated and moving into numpy
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement