Create a Cryptographically Random Number - CSharp Security

CSharp examples for Security:Random Number

Description

Create a Cryptographically Random Number

Demo Code


using System;/*  w  ww.  j  a v  a2 s . c  o  m*/
using System.Security.Cryptography;

class MainClass
    {
        public static void Main() {

            byte[] number = new byte[32];

            RandomNumberGenerator rng = RandomNumberGenerator.Create();

            rng.GetBytes(number);

            Console.WriteLine(BitConverter.ToString(number));

        }
    }

Result


Related Tutorials