Thursday, 15 January 2015

.net - Generate several megabytes of of random data in C# -


I want to know a great way to generate random data of several megabytes using C # on Windows (.net) 2.0), but other options such as other options such as .NET 3.0 and Mono libraries will also have some interest).

The purpose of the data is to communicate through a real network network, for certain destinations, so the level of randomness is not really important - although the data is somewhat of an appetite (like repeating characters Series) should not be anything.

I can use random, or generate a GUID I'm curious to know if there are better ways to do this. What is analog to / dev / urandom on UNIX for example?

You can generate this approach to use random number stream:

< Pre> int streamus = (1024 * 1024) * 15; // let's squeeze 15 MBits junk int byte = stream; While (Left & gt; 0) {RNGCryptoServiceProvider rng = New RNGCryptoServiceProvider (); Byte [] buffer = new byte [1024]; RNG. Bats (buffer); Sendbats (buffer); // Leave it on the network interface - = 1024; }

No comments:

Post a Comment