Simulating /dev/random on Windows

If you are using Python, why do you care about the specific implementation? Just use the random module and let it deal with it.

Beyond that, (if you can't rely on software state) os.urandom provides os-based random values:

On a UNIX-like system this will query /dev/urandom, and on Windows it will use CryptGenRandom.

(Note that random.SystemRandom provides a nice interface for this).

If you are really serious about it being cryptographically random, you might want to check out PyCrypto.


You could call random.SystemRandom instead. This will use CryptGenRandom on Windows and /dev/urandom on Linux.

Otherwise, there's always Cygwin's /dev/random?