C# Class GSF.Security.Cryptography.Random

Generates cryptographically strong random numbers.
ファイルを表示 Open project: GridProtectionAlliance/gsf Class Usage Examples

Public Methods

Method Description
Between ( double startNumber, double stopNumber ) : double

Generates a semi cryptographically strong random integer between specified values. i.e. [startNumber-stopNumber)

ByteBetween ( byte startNumber, byte stopNumber ) : byte

Generates a cryptographically strong 8-bit random integer between specified values. i.e. [startNumber-stopNumber)

GetBytes ( byte buffer ) : void

Fills an array of bytes with a cryptographically strong sequence of random values.

The length of the byte array determines how many cryptographically strong random bytes are produced.

This method is thread safe.

Int16Between ( short startNumber, short stopNumber ) : short

Generates a cryptographically strong 16-bit random integer between specified values. i.e. [startNumber-stopNumber)

Int24Between ( Int24 startNumber, Int24 stopNumber ) : Int24

Generates a cryptographically strong 24-bit random integer between specified values. i.e. [startNumber-stopNumber)

Int24Between ( System.UInt24 startNumber, System.UInt24 stopNumber ) : System.UInt24

Generates a cryptographically strong unsigned 24-bit random integer between specified values. i.e. [startNumber-stopNumber)

Int32Between ( int startNumber, int stopNumber ) : int

Generates a cryptographically strong 32-bit random integer between specified values. i.e. [startNumber-stopNumber)

Int64Between ( long startNumber, long stopNumber ) : long

Generates a cryptographically strong 64-bit random integer between specified values. i.e. [startNumber-stopNumber)

UInt16Between ( ushort startNumber, ushort stopNumber ) : ushort

Generates a cryptographically strong unsigned 16-bit random integer between specified values. i.e. [startNumber-stopNumber)

UInt32Between ( uint startNumber, uint stopNumber ) : uint

Generates a cryptographically strong unsigned 32-bit random integer between specified values. i.e. [startNumber-stopNumber)

UInt64Between ( ulong startNumber, ulong stopNumber ) : ulong

Generates a cryptographically strong unsigned 64-bit random integer between specified values. i.e. [startNumber-stopNumber)

Private Methods

Method Description
GetRandomNumberLessThan ( int maxValue ) : int

Returns a cryptographically strong number that is less the the supplied value

A number less than a negative number rolls down to int.MinValue, then to int.MaxValue if 0 is provided, 0 is returned

GetRandomNumberLessThan ( long maxValue ) : long

Returns a cryptographically strong number that is less the the supplied value

A number less than a negative number rolls down to long.MinValue, then to long.MaxValue if 0 is provided, 0 is returned

GetRandomNumberLessThan ( uint maxValue ) : uint

Returns a cryptographically strong number that is less than the the supplied value

if 0 is provided, 0 is returned

GetRandomNumberLessThan ( ulong maxValue ) : ulong

Returns a cryptographically strong number that is less than the the supplied value

if 0 is provided, 0 is returned

Method Details

Between() public static method

Generates a semi cryptographically strong random integer between specified values. i.e. [startNumber-stopNumber)
The cryptographic service provider (CSP) cannot be acquired.
public static Between ( double startNumber, double stopNumber ) : double
startNumber double A that is the low end of our range.
stopNumber double A that is the high end of our range.
return double

ByteBetween() public static method

Generates a cryptographically strong 8-bit random integer between specified values. i.e. [startNumber-stopNumber)
The cryptographic service provider (CSP) cannot be acquired.
public static ByteBetween ( byte startNumber, byte stopNumber ) : byte
startNumber byte A that is the low end of our range.
stopNumber byte A that is the high end of our range.
return byte

GetBytes() public static method

Fills an array of bytes with a cryptographically strong sequence of random values.

The length of the byte array determines how many cryptographically strong random bytes are produced.

This method is thread safe.

The cryptographic service provider (CSP) cannot be acquired. buffer is null.
public static GetBytes ( byte buffer ) : void
buffer byte The array to fill with a cryptographically strong sequence of random values.
return void

Int16Between() public static method

Generates a cryptographically strong 16-bit random integer between specified values. i.e. [startNumber-stopNumber)
The cryptographic service provider (CSP) cannot be acquired.
public static Int16Between ( short startNumber, short stopNumber ) : short
startNumber short A that is the low end of our range.
stopNumber short A that is the high end of our range.
return short

Int24Between() public static method

Generates a cryptographically strong 24-bit random integer between specified values. i.e. [startNumber-stopNumber)
The cryptographic service provider (CSP) cannot be acquired.
public static Int24Between ( Int24 startNumber, Int24 stopNumber ) : Int24
startNumber Int24 A that is the low end of our range.
stopNumber Int24 A that is the high end of our range.
return Int24

Int24Between() public static method

Generates a cryptographically strong unsigned 24-bit random integer between specified values. i.e. [startNumber-stopNumber)
The cryptographic service provider (CSP) cannot be acquired.
public static Int24Between ( System.UInt24 startNumber, System.UInt24 stopNumber ) : System.UInt24
startNumber System.UInt24 A that is the low end of our range.
stopNumber System.UInt24 A that is the high end of our range.
return System.UInt24

Int32Between() public static method

Generates a cryptographically strong 32-bit random integer between specified values. i.e. [startNumber-stopNumber)
The cryptographic service provider (CSP) cannot be acquired.
public static Int32Between ( int startNumber, int stopNumber ) : int
startNumber int A that is the low end of our range.
stopNumber int A that is the high end of our range.
return int

Int64Between() public static method

Generates a cryptographically strong 64-bit random integer between specified values. i.e. [startNumber-stopNumber)
The cryptographic service provider (CSP) cannot be acquired.
public static Int64Between ( long startNumber, long stopNumber ) : long
startNumber long A that is the low end of our range.
stopNumber long A that is the high end of our range.
return long

UInt16Between() public static method

Generates a cryptographically strong unsigned 16-bit random integer between specified values. i.e. [startNumber-stopNumber)
The cryptographic service provider (CSP) cannot be acquired.
public static UInt16Between ( ushort startNumber, ushort stopNumber ) : ushort
startNumber ushort A that is the low end of our range.
stopNumber ushort A that is the high end of our range.
return ushort

UInt32Between() public static method

Generates a cryptographically strong unsigned 32-bit random integer between specified values. i.e. [startNumber-stopNumber)
The cryptographic service provider (CSP) cannot be acquired.
public static UInt32Between ( uint startNumber, uint stopNumber ) : uint
startNumber uint A that is the low end of our range.
stopNumber uint A that is the high end of our range.
return uint

UInt64Between() public static method

Generates a cryptographically strong unsigned 64-bit random integer between specified values. i.e. [startNumber-stopNumber)
The cryptographic service provider (CSP) cannot be acquired.
public static UInt64Between ( ulong startNumber, ulong stopNumber ) : ulong
startNumber ulong A that is the low end of our range.
stopNumber ulong A that is the high end of our range.
return ulong