On Wed, 10 Nov 2004 22:42:02 -0500, Vijay M <[EMAIL PROTECTED]> wrote:
> RNGCryptoServiceProvider class in
> System.Security.Cryptography.RandomNumberGenerator is to create random
> bytes, more useful for creating random keys to encrypt data, i think. It is
> a derived class of the RandomNumberGenerator class. Dont think this will be
> useful in my case !
>

The following code produces about a half-million random 32-bit
integers/sec. on my Pentium M 1.7Ghz based Latitude D800:

byte[] buf = new byte[4];

RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();

int val = Rand(buf, rng);

...

int Rand(byte[] buffer, RNGCryptoServiceProvider rng)
{
        rng.GetBytes(buffer);
        return BitConverter.ToInt32(buffer, 0);
}


--
Steve Johnson

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
Some .NET courses you may be interested in:

Essential .NET: building applications and components with C#
November 29 - December 3, in Los Angeles
http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to