Generate 32 bytes of random data : RandomNumberGenerator : Security C# Examples


C# Examples » Security » RandomNumberGenerator »

 

Generate 32 bytes of random data









    
using  System;
using  System.Security.Cryptography;

class  MainClass
{
        public  static  void  Main()  {
                byte[]  number  =  new  byte[32];
                
                RandomNumberGenerator  rng  =  RandomNumberGenerator.Create();
                
                
                rng.GetBytes(number);
                
                //  Display  the  random  number.
                Console.WriteLine(BitConverter.ToString(number));

        }
}
    
   
  
   



Output

B9-33-DA-50-FB-D0-A7-7A-6D-7C-12-A7-47-A5-FE-45-F0-E0-DC-87-AE-27-CE-C0-76-D5-85-5C-DF-7D-4A-82


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Security
» RandomNumberGenerator