Reputation: 10929
Is there a way to generate random number on Windows by reading from a file or pseudo file or character special file, the way that can be done on Linux by reading from /dev/random? Not asking about various crypto API, but whether there is in Windows something akin to the Linux way.
Upvotes: 60
Views: 24107
Reputation: 5379
This link from StingyJack's answer is good: http://en.wikipedia.org/wiki/CryptGenRandom
Microsoft C++ Visual Studio since 2005 offers rand_s()
which works on Windows XP and up. It is based on RtlGenRandom
(as are CryptoAPI's PRNG functions), whose inner workings are not made public. It seems in XP there were some weaknesses that have since been fixed.
Personally, I use rand_s()
as an additional source of randomness to seed a PRNG of my choice.
Upvotes: 2
Reputation: 532555
If you're doing .NET development you can use the RandomNumberGenerator class.
Upvotes: 0