I’m trying to port python code from linux to windows right now. In various places random numbers are generateted by reading from /dev/random. Is there a way to simulate /dev/random on Windows?
I’m looking for a solution that would keep the code useable on linux…
If you are using Python, why do you care about the specific implementation? Just use the
randommodule and let it deal with it.Beyond that, (if you can’t rely on software state)
os.urandomprovides os-based random values:(Note that
random.SystemRandomprovides a nice interface for this).If you are really serious about it being cryptographically random, you might want to check out PyCrypto.