Show / Hide Table of Contents

Class Crypto

Inheritance
System.Object
Crypto
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: SIPSorcery.Sys
Assembly: SIPSorcery.dll
Syntax
public class Crypto

Fields

| Improve this Doc View Source

AES_IV_SIZE

Declaration
public const int AES_IV_SIZE = 16
Field Value
Type Description
System.Int32
| Improve this Doc View Source

AES_KEY_SIZE

Declaration
public const int AES_KEY_SIZE = 32
Field Value
Type Description
System.Int32
| Improve this Doc View Source

DEFAULT_RANDOM_LENGTH

Declaration
public const int DEFAULT_RANDOM_LENGTH = 10
Field Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

createRandomSalt(Int32)

Declaration
public static byte[] createRandomSalt(int length)
Parameters
Type Name Description
System.Int32 length
Returns
Type Description
System.Byte[]
| Improve this Doc View Source

GetHash(String)

This version 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 different hashes across different platforms.

Declaration
public static string GetHash(string filepath)
Parameters
Type Name Description
System.String filepath
Returns
Type Description
System.String
| Improve this Doc View Source

GetRandomBytes(Byte[])

Fills a buffer with random bytes.

Declaration
public static void GetRandomBytes(byte[] buffer)
Parameters
Type Name Description
System.Byte[] buffer

The buffer to fill.

| Improve this Doc View Source

GetRandomByteString(Int32)

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

Declaration
public static string GetRandomByteString(int byteLength)
Parameters
Type Name Description
System.Int32 byteLength

The byte length of the random number string to obtain.

Returns
Type Description
System.String

A string representation of the random number. It will be twice the length of byteLength.

| Improve this Doc View Source

GetRandomInt()

Returns a 10 digit random number.

Declaration
public static int GetRandomInt()
Returns
Type Description
System.Int32
| Improve this Doc View Source

GetRandomInt(Int32)

Returns a random number of a specified length.

Declaration
public static int GetRandomInt(int length)
Parameters
Type Name Description
System.Int32 length
Returns
Type Description
System.Int32
| Improve this Doc View Source

GetRandomInt(Int32, Int32)

Declaration
public static int GetRandomInt(int minValue, int maxValue)
Parameters
Type Name Description
System.Int32 minValue
System.Int32 maxValue
Returns
Type Description
System.Int32
| Improve this Doc View Source

GetRandomString()

Declaration
public static string GetRandomString()
Returns
Type Description
System.String
| Improve this Doc View Source

GetRandomString(Int32)

Declaration
public static string GetRandomString(int length)
Parameters
Type Name Description
System.Int32 length
Returns
Type Description
System.String
| Improve this Doc View Source

GetRandomUInt(Boolean)

Declaration
public static uint GetRandomUInt(bool noZero = false)
Parameters
Type Name Description
System.Boolean noZero
Returns
Type Description
System.UInt32
| Improve this Doc View Source

GetRandomUInt16()

Declaration
public static ushort GetRandomUInt16()
Returns
Type Description
System.UInt16
| Improve this Doc View Source

GetRandomULong()

Declaration
public static ulong GetRandomULong()
Returns
Type Description
System.UInt64
| Improve this Doc View Source

GetSHA256Hash(Byte[])

Gets the HSA256 hash of an arbitrary buffer.

Declaration
public static string GetSHA256Hash(byte[] buffer)
Parameters
Type Name Description
System.Byte[] buffer

The buffer to hash.

Returns
Type Description
System.String

A hex string representing the hashed buffer.

| Improve this Doc View Source

GetSHAHash(String[])

Declaration
public static byte[] GetSHAHash(params string[] values)
Parameters
Type Name Description
System.String[] values
Returns
Type Description
System.Byte[]
| Improve this Doc View Source

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.

Declaration
public static string GetSHAHashAsHex(params string[] values)
Parameters
Type Name Description
System.String[] values

The list of string to concatenate and hash.

Returns
Type Description
System.String

A string with "safe" (0-9 and A-F) characters representing the hash.

| Improve this Doc View Source

GetSHAHashAsString(String[])

Declaration
public static string GetSHAHashAsString(params string[] values)
Parameters
Type Name Description
System.String[] values
Returns
Type Description
System.String
| Improve this Doc View Source

LoadCertificate(StoreLocation, String, Boolean)

Attempts to load an X509 certificate from a Windows OS certificate store.

Declaration
public static X509Certificate2 LoadCertificate(StoreLocation storeLocation, string certificateSubject, bool checkValidity)
Parameters
Type Name Description
System.Security.Cryptography.X509Certificates.StoreLocation storeLocation

The certificate store to load from, can be CurrentUser or LocalMachine.

System.String certificateSubject

The subject name of the certificate to attempt to load.

System.Boolean checkValidity

Checks if the certificate is current and has a verifiable certificate issuer list. Should be set to false for self issued certificates.

Returns
Type Description
System.Security.Cryptography.X509Certificates.X509Certificate2

A certificate object if the load is successful otherwise null.

| Improve this Doc View Source

Rand()

Declaration
public static int Rand()
Returns
Type Description
System.Int32
| Improve this Doc View Source

Rand(Int32)

Declaration
public static int Rand(int maxValue)
Parameters
Type Name Description
System.Int32 maxValue
Returns
Type Description
System.Int32
| Improve this Doc View Source

SymmetricDecrypt(String, String, Byte[])

Declaration
public static string SymmetricDecrypt(string key, string iv, byte[] cipherBytes)
Parameters
Type Name Description
System.String key
System.String iv
System.Byte[] cipherBytes
Returns
Type Description
System.String
| Improve this Doc View Source

SymmetricDecrypt(String, String, String)

Declaration
public static string SymmetricDecrypt(string key, string iv, string cipherText)
Parameters
Type Name Description
System.String key
System.String iv
System.String cipherText
Returns
Type Description
System.String
| Improve this Doc View Source

SymmetricEncrypt(String, String, Byte[])

Declaration
public static string SymmetricEncrypt(string key, string iv, byte[] plainTextBytes)
Parameters
Type Name Description
System.String key
System.String iv
System.Byte[] plainTextBytes
Returns
Type Description
System.String
| Improve this Doc View Source

SymmetricEncrypt(String, String, String)

Declaration
public static string SymmetricEncrypt(string key, string iv, string plainText)
Parameters
Type Name Description
System.String key
System.String iv
System.String plainText
Returns
Type Description
System.String

Extension Methods

JSONWriter.ToJson(Object)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX