Secure Random Numbers

Date: 2019-11-05

https://stackoverflow.com/a/37804448

// **Note: ** .NET Core 2.0.0+ uses a different seed on the parameterless constructor: instead of CPU clock it uses Guid.NewGuid().GetHashCode().

var random = new Random();
int randomnumber = random.Next()

// While the RNGCryptoServiceProvider class uses OS entropy to generate //seeds. OS entropy is a random value which is generated using sound, mouse click, and keyboard timings, thermal temp etc. Below goes the code for the same.

using (RNGCryptoServiceProvider rg = new RNGCryptoServiceProvider()) 
{ 
    byte[] rno = new byte[5];    
    rg.GetBytes(rno);    
    int randomvalue = BitConverter.ToInt32(rno, 0); 
}
28110cookie-checkSecure Random Numbers