isRandomSecure

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");
}

Description

blowdart random test

Details

  • Author: Ben Adams
  • Submitted on: 8/4/2016 5:55:30 AM
  • Language: C#
  • Type: int
  • Views: 954

Double click on the code to select all.

 

;