Re: Does this generate a 64 bit random number

From: george r smith (gsmith_at_budgetext.com)
Date: 10/24/03


Date: Fri, 24 Oct 2003 14:33:37 -0500

I forgot to ask how can I print out the random numbers.

"george r smith" <gsmith@budgetext.com> wrote in message
news:uUEuEKmmDHA.1800@TK2MSFTNGP10.phx.gbl...
> Hi all,
> I am trying to create a 64 bit random number using the
> System.Security.Cryptography. Is the following code
> how to do it (I know it does work but is it correct).
>
> Also, is this newsgroup the Microsoft Managed Newsgroups that
> they speak of in the MSDN site.
>
> thanks
> grs
>
> namespace rng_001
> {
> /// <summary>
> /// Summary description RandomNumberGenerator
> /// </summary>
> class RandomNumberGenerator
> {
> public static System.UInt64[] keys = new System.UInt64[3];
> /// <summary>
> /// The main entry point for the application.
> /// </summary>
> [STAThread]
> static void Main(string[] args)
> {
> byte[] random = new Byte[8];
> RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
> for (int count = 0; count < 3; count++)
> {
> rng.GetBytes(random);
> keys[count] = BitConverter.ToUInt64(random,0);
> }
> Console.ReadLine();
> }
> }
> }
>
>