C# Class SIPSorcery.Sys.Crypto

Afficher le fichier Open project: sipsorcery/sipsorcery

Méthodes publiques

Méthode 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

Méthode 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 méthode

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
Résultat string

GetRSAProvider() public static méthode

public static GetRSAProvider ( string xmlKey ) : RSACryptoServiceProvider
xmlKey string
Résultat System.Security.Cryptography.RSACryptoServiceProvider

GetRandomByteString() public static méthode

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.
Résultat string

GetRandomInt() public static méthode

public static GetRandomInt ( Int32 minValue, Int32 maxValue ) : Int32
minValue System.Int32
maxValue System.Int32
Résultat System.Int32

GetRandomInt() public static méthode

Returns a 10 digit random number.
public static GetRandomInt ( ) : int
Résultat int

GetRandomInt() public static méthode

Returns a random number of a specified length.
public static GetRandomInt ( int length ) : int
length int
Résultat int

GetRandomString() public static méthode

public static GetRandomString ( ) : string
Résultat string

GetRandomString() public static méthode

public static GetRandomString ( int length ) : string
length int
Résultat string

GetRandomUInt() public static méthode

public static GetRandomUInt ( ) : UInt32
Résultat System.UInt32

GetRandomUInt16() public static méthode

public static GetRandomUInt16 ( ) : UInt16
Résultat System.UInt16

GetSHAHash() public static méthode

public static GetSHAHash ( ) : byte[]
Résultat byte[]

GetSHAHashAsHex() public static méthode

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
Résultat string

GetSHAHashAsString() public static méthode

public static GetSHAHashAsString ( ) : string
Résultat string

RSADecrypt() public static méthode

public static RSADecrypt ( string xmlKey, string cypherText ) : string
xmlKey string
cypherText string
Résultat string

RSADecryptRaw() public static méthode

public static RSADecryptRaw ( string xmlKey, byte cypher ) : byte[]
xmlKey string
cypher byte
Résultat byte[]

RSAEncrypt() public static méthode

public static RSAEncrypt ( string xmlKey, string plainText ) : string
xmlKey string
plainText string
Résultat string

RSAEncryptRaw() public static méthode

public static RSAEncryptRaw ( string xmlKey, string plainText ) : byte[]
xmlKey string
plainText string
Résultat byte[]

SymmetricDecrypt() public static méthode

public static SymmetricDecrypt ( string key, string iv, byte cipherBytes ) : string
key string
iv string
cipherBytes byte
Résultat string

SymmetricDecrypt() public static méthode

public static SymmetricDecrypt ( string key, string iv, string cipherText ) : string
key string
iv string
cipherText string
Résultat string

SymmetricEncrypt() public static méthode

public static SymmetricEncrypt ( string key, string iv, byte plainTextBytes ) : string
key string
iv string
plainTextBytes byte
Résultat string

SymmetricEncrypt() public static méthode

public static SymmetricEncrypt ( string key, string iv, string plainText ) : string
key string
iv string
plainText string
Résultat string

createRandomSalt() public static méthode

public static createRandomSalt ( int length ) : byte[]
length int
Résultat byte[]