C# Class SIPSorcery.Sys.Crypto

Show file Open project: sipsorcery/sipsorcery

Public Methods

Method Description
GetHash ( string filepath ) : string

This vesion reads the whole file in at once. This is not great since it can consume a lot of memory if the file is large. However a buffered approach generates diferrent hashes across different platforms.

GetRSAProvider ( string xmlKey ) : RSACryptoServiceProvider
GetRandomByteString ( int byteLength ) : string

Gets an "X2" string representation of a random number.

GetRandomInt ( Int32 minValue, Int32 maxValue ) : Int32
GetRandomInt ( ) : int

Returns a 10 digit random number.

GetRandomInt ( int length ) : int

Returns a random number of a specified length.

GetRandomString ( ) : string
GetRandomString ( int length ) : string
GetRandomUInt ( ) : UInt32
GetRandomUInt16 ( ) : UInt16
GetSHAHash ( ) : byte[]
GetSHAHashAsHex ( ) : 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.

GetSHAHashAsString ( ) : string
RSADecrypt ( string xmlKey, string cypherText ) : string
RSADecryptRaw ( string xmlKey, byte cypher ) : byte[]
RSAEncrypt ( string xmlKey, string plainText ) : string
RSAEncryptRaw ( string xmlKey, string plainText ) : byte[]
SymmetricDecrypt ( string key, string iv, byte cipherBytes ) : string
SymmetricDecrypt ( string key, string iv, string cipherText ) : string
SymmetricEncrypt ( string key, string iv, byte plainTextBytes ) : string
SymmetricEncrypt ( string key, string iv, string plainText ) : string
createRandomSalt ( int length ) : byte[]

Private Methods

Method Description
GetFileStream ( string filepath ) : FileStream

Used by methods wishing to perform a hash operation on a file. This method will perform a number of checks and if happy return a read only file stream.

GetFixedLengthByteArray ( string value, int length ) : byte[]

Method Details

GetHash() public static method

This vesion reads the whole file in at once. This is not great since it can consume a lot of memory if the file is large. However a buffered approach generates diferrent hashes across different platforms.
public static GetHash ( string filepath ) : string
filepath string
return string

GetRSAProvider() public static method

public static GetRSAProvider ( string xmlKey ) : RSACryptoServiceProvider
xmlKey string
return System.Security.Cryptography.RSACryptoServiceProvider

GetRandomByteString() public static method

Gets an "X2" string representation of a random number.
public static GetRandomByteString ( int byteLength ) : string
byteLength int The byte length of the random number string to obtain.
return string

GetRandomInt() public static method

public static GetRandomInt ( Int32 minValue, Int32 maxValue ) : Int32
minValue System.Int32
maxValue System.Int32
return System.Int32

GetRandomInt() public static method

Returns a 10 digit random number.
public static GetRandomInt ( ) : int
return int

GetRandomInt() public static method

Returns a random number of a specified length.
public static GetRandomInt ( int length ) : int
length int
return int

GetRandomString() public static method

public static GetRandomString ( ) : string
return string

GetRandomString() public static method

public static GetRandomString ( int length ) : string
length int
return string

GetRandomUInt() public static method

public static GetRandomUInt ( ) : UInt32
return System.UInt32

GetRandomUInt16() public static method

public static GetRandomUInt16 ( ) : UInt16
return System.UInt16

GetSHAHash() public static method

public static GetSHAHash ( ) : byte[]
return byte[]

GetSHAHashAsHex() public static method

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.
public static GetSHAHashAsHex ( ) : string
return string

GetSHAHashAsString() public static method

public static GetSHAHashAsString ( ) : string
return string

RSADecrypt() public static method

public static RSADecrypt ( string xmlKey, string cypherText ) : string
xmlKey string
cypherText string
return string

RSADecryptRaw() public static method

public static RSADecryptRaw ( string xmlKey, byte cypher ) : byte[]
xmlKey string
cypher byte
return byte[]

RSAEncrypt() public static method

public static RSAEncrypt ( string xmlKey, string plainText ) : string
xmlKey string
plainText string
return string

RSAEncryptRaw() public static method

public static RSAEncryptRaw ( string xmlKey, string plainText ) : byte[]
xmlKey string
plainText string
return byte[]

SymmetricDecrypt() public static method

public static SymmetricDecrypt ( string key, string iv, byte cipherBytes ) : string
key string
iv string
cipherBytes byte
return string

SymmetricDecrypt() public static method

public static SymmetricDecrypt ( string key, string iv, string cipherText ) : string
key string
iv string
cipherText string
return string

SymmetricEncrypt() public static method

public static SymmetricEncrypt ( string key, string iv, byte plainTextBytes ) : string
key string
iv string
plainTextBytes byte
return string

SymmetricEncrypt() public static method

public static SymmetricEncrypt ( string key, string iv, string plainText ) : string
key string
iv string
plainText string
return string

createRandomSalt() public static method

public static createRandomSalt ( int length ) : byte[]
length int
return byte[]