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. Commented Jun 2, 2017 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 Commented Jun 2, 2017 at 18:58
  • 1
    @DavidScholefield /dev/random isn't true random either. It's a PRGN that's seeded from an entropy pool.
    – Xander
    Commented Jun 2, 2017 at 19:01
  • is it? OK, I'll go and check that out, I thought it was purely random from UI input... Commented Jun 2, 2017 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
    Commented Jun 2, 2017 at 19:10

1 Answer 1


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
    Commented Jun 2, 2017 at 18:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .