isRandomSecure
blowdart random test
Source
private static RandomNumberGenerator rand = System.Security.Cryptography.RandomNumberGenerator.Create();
public static bool isRandomSecure(this int source)
{
var data = new byte[4];
rand.GetBytes(data);
return source == ((data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]);
}
Example
var num = 10;
if( num.isRandomSecure() ) {
Console.WriteLine("num is random");
}
else {
Console.WriteLine("num is not random");
}