Is there a pseudo device-based random data stream/file that can be used in Windows .NET programming in the same way as /dev/random can be read and used as a source of random values on Linux based systems?

I’m not asking whether .NET can provide a pseudo-random number generator type random call such as CryptGenRandom() which appears to use a random seed to create a sequence of PRNG numbers but whether there is a functional equivalent as /dev/random which stores various system events and UI interaction to create a pool of random values that are considered to be crypto secure.

Because /dev/random appears to be similar to any other file on the underlying system, any Linux based programming language can access this truly random stream of data, but C# and other .NET programs don’t (normally) run on Linux systems, and mine certainly don’t.

All online searches and my reading always leads me to information about PRNG calls, which is not the same thing at all.

If there’s any answer to this on here already then I just need more practice on searching for answers I guess!

  • You could write a program that outputs data from CryptGenRandom to stdout and then pipe it into the target program. Jun 2 '17 at 18:06
  • Ah, but that's a PRNG and that isn't truly random - I can call CryptGenRandom() from my .NET program but I want a 'truly' random source Jun 2 '17 at 18:58
  • 1
    @DavidScholefield /dev/random isn't true random either. It's a PRGN that's seeded from an entropy pool.
    – Xander
    Jun 2 '17 at 19:01
  • is it? OK, I'll go and check that out, I thought it was purely random from UI input... Jun 2 '17 at 19:02
  • That is indeed one of the (many) sources it draws from to feed the entropy pool. More information here: 2uo.de/myths-about-urandom
    – Xander
    Jun 2 '17 at 19:10

There is no built-in file-like interface to a source of randomness or entropy, if that is what you mean.

Unix-style operating systems such as Linux try to fit everything in a file, but Windows doesn't adhere to that approach and uses a function call instead.

This page has a random device driver to create a file like /dev/random on Windows. I don't know how well that works, and it uses RtlRandom and not CryptGenRandom.

  • 1
    As a quick note, RtlRandom is not a cryptographically secure PRNG. CryptGenRandom and RtlGenRandom however, are.
    – Xander
    Jun 2 '17 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.