Simulate / dev / random on Windows

I am trying to port python code from linux to windows right now. In different places, random numbers are generated by reading from / dev / random. Is there a way to simulate / dev / random on Windows?

I am looking for a solution that will allow the use of code in linux ...

+7
source share
3 answers

If you use Python, why are you interested in a particular implementation? Just use the random module and let it handle it.

Other than that (if you cannot rely on the state of the software) os.urandom provides random values โ€‹โ€‹based on os:

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

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

If you're seriously really cryptographically random, you can check out PyCrypto .

+13
source

Instead, you can call random.SystemRandom . This will use CryptGenRandom for Windows and / dev / urandom on Linux.

Otherwise, is there always Cygwin / dev / random?

+7
source

You can use random from the standard Python library.

+1
source

All Articles