C# Class Jebtek.RdRand.RdRandom

Mostrar archivo Open project: JebteK/RdRand Class Usage Examples

Public Methods

Method Description
GenerateAPIKey ( ) : string

Generates a 64 character long key that can be used as an API key. This can only be run on compatible Intel CPUs.

GenerateBytes ( int length ) : byte[]

Uses the RDRAND instrution on Intel IvyBridge and higher CPUs to return truely random byte arrays. CAUTION: If this code is executed on non IvyBridge CPUs, it will return null!

GenerateKey ( int length ) : string

Returns a base64 encoded string of a series of random(perhaps ish) bytes. On Intel IvyBridge and higher CPUs, the byte array is truely random, using the RDRAND assembly instruction to get the CPU to retrieve them. On other processors, the byte array is pseudo random, using the current time as a seed value.

GenerateUnsignedInt ( ) : uint

Uses the RDRAND instrution on Intel IvyBridge and higher CPUs to return truely random integers. CAUTION: If this code is executed on non IvyBridge CPUs, it will return null!

GeneratorAvailable ( ) : bool

Checks for CPU compatibility with the RDRAND instruction. The RDRAND instruction is only available on Intel IvyBridge and higher CPUs.

Private Methods

Method Description
IntToBytes ( uint input ) : byte[]

Method Details

GenerateAPIKey() public static method

Generates a 64 character long key that can be used as an API key. This can only be run on compatible Intel CPUs.
public static GenerateAPIKey ( ) : string
return string

GenerateBytes() public static method

Uses the RDRAND instrution on Intel IvyBridge and higher CPUs to return truely random byte arrays. CAUTION: If this code is executed on non IvyBridge CPUs, it will return null!
public static GenerateBytes ( int length ) : byte[]
length int Size of the byte array
return byte[]

GenerateKey() public static method

Returns a base64 encoded string of a series of random(perhaps ish) bytes. On Intel IvyBridge and higher CPUs, the byte array is truely random, using the RDRAND assembly instruction to get the CPU to retrieve them. On other processors, the byte array is pseudo random, using the current time as a seed value.
public static GenerateKey ( int length ) : string
length int Length (in bytes) / size of the byte array
return string

GenerateUnsignedInt() public static method

Uses the RDRAND instrution on Intel IvyBridge and higher CPUs to return truely random integers. CAUTION: If this code is executed on non IvyBridge CPUs, it will return null!
public static GenerateUnsignedInt ( ) : uint
return uint

GeneratorAvailable() public static method

Checks for CPU compatibility with the RDRAND instruction. The RDRAND instruction is only available on Intel IvyBridge and higher CPUs.
public static GeneratorAvailable ( ) : bool
return bool