Class Crypto
Class containing various cryptography utilities
Inherited Members
Namespace: SipLib.Core
Assembly: SipLib.dll
Syntax
public class Crypto
Methods
| Edit this page View SourceGetRandomByteArray(byte[], int, int)
Fills an array of bytes with random numbers.
Declaration
public static void GetRandomByteArray(byte[] buffer, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | Destination |
int | offset | Starting index in the destination buffer |
int | length | Number of bytes to write |
GetRandomByteString(int)
Gets an "X2" string representation of a random number.
Declaration
public static string GetRandomByteString(int byteLength)
Parameters
Type | Name | Description |
---|---|---|
int | byteLength | The byte length of the random number string to obtain. |
Returns
Type | Description |
---|---|
string | A string representation of the random number. It will be twice the length of byteLength. |
GetRandomInt()
Returns a 10 digit random number.
Declaration
public static int GetRandomInt()
Returns
Type | Description |
---|---|
int |
GetRandomInt(int)
Returns a random number of a specified length.
Declaration
public static int GetRandomInt(int length)
Parameters
Type | Name | Description |
---|---|---|
int | length |
Returns
Type | Description |
---|---|
int |
GetRandomInt(int, int)
Generates a 32-bit random number between a minimum and a maximum value.
Declaration
public static int GetRandomInt(int minValue, int maxValue)
Parameters
Type | Name | Description |
---|---|---|
int | minValue | |
int | maxValue |
Returns
Type | Description |
---|---|
int |
GetRandomString()
Creates a random string of characters. The length is DEFAULT_RANDOM_LENGTH
Declaration
public static string GetRandomString()
Returns
Type | Description |
---|---|
string | The random string |
GetRandomString(int)
Creates a string of random characters
Declaration
public static string GetRandomString(int length)
Parameters
Type | Name | Description |
---|---|---|
int | length | Desired length of the string |
Returns
Type | Description |
---|---|
string | Random string of random alphabet characters |
GetRandomUInt()
Gets a unsigned 32 bit random number
Declaration
public static uint GetRandomUInt()
Returns
Type | Description |
---|---|
uint |
GetRandomUInt16()
Gets a 16 bit unsigned random number
Declaration
public static ushort GetRandomUInt16()
Returns
Type | Description |
---|---|
ushort |
GetSHAHash(params string[])
Gets the SHA1 hash of an array of string values
Declaration
public static byte[] GetSHAHash(params string[] values)
Parameters
Type | Name | Description |
---|---|---|
string[] | values |
Returns
Type | Description |
---|---|
byte[] |
GetSHAHashAsHex(params string[])
Returns the hash with each byte as an X2 string. This is useful for situations where the hash needs to only contain safe ASCII characters.
Declaration
public static string GetSHAHashAsHex(params string[] values)
Parameters
Type | Name | Description |
---|---|---|
string[] | values | The list of string to concantenate and hash. |
Returns
Type | Description |
---|---|
string | A string with "safe" (0-9 and A-F) characters representing the hash. |