YottaRandom

About this project
The stupidest random number generator you'll find (I hope).
Wiki / Home

This is the stupidest random number generator I hope you'll find on the Internet. For more information to support this aspiration, and learn more technical details, see my Yotta Random web page.

The core of the stupid random number generator is the YottaStream class which is derived directly from the abstract Stream class. It implements the Read and ReadAsync methods to deliver a basic read-only sequence of random bytes.

Any app stupid enough to use YottaStream is highly encouraged to wrap it in a buffered stream like this:

using (var ys = new YottaStream())
using (var bs = new BufferedStream(ys, 1024))
{
  byte[] buffer = new byte[64];
  bs.Read(buffer, 0, buffer.Length);
}

This creates a read-ahead buffer of 1024 bytes for more efficient retrieval of random bytes in the case where the app is making unpredictable demands that are generally less than that length. You would adjust the buffer size according to demands.

Note that the internal process of updating the random state buffer makes asynchronous web service calls, so calling Read is a thread blocking operation and ReadAsync is preferred.

The library contains another class named YottaRandom which is derived from the standard Random class. It only exists as an academic exercise to create a Random compatible class that uses the YottaStream class internally. One curious difference though is that it implements IDisposable because it internally uses a Stream.

If you really need a trusted source of the highest quality random numbers, then the best choice is probably a site that is distilling real random numbers from natural sources such as electrical white noise, radioactivity or the quantum world. There used to be a few entertaining free web sites that published such randomness over web services, but sadly they have all moved behind paywalls. For more comments on this see my blog post Real Random Numbers .

Orthogonal Programming Link