Table of Contents

Class Encryption

Namespace
ArcanaDevelopment.adTempus.Shared
Assembly
ArcanaDevelopment.adTempus.Shared.dll
public static class Encryption
Inheritance
object
Encryption

Fields

KeySize

public const int KeySize = 24

Field Value

int

SHA256OID

The OID to use when signing using SHA256 algorithm.

public const string SHA256OID = "2.16.840.1.101.3.4.2.1"

Field Value

string

Remarks

Do not use CryptoConfig.MapNameToOID, because on some older .NET versions there will not be a mapping for the name.

Properties

RandomNumberGenerator

public static RandomNumberGenerator RandomNumberGenerator { get; }

Property Value

RandomNumberGenerator

Methods

CreateSessionKey()

Creates a block of random bytes that can be used as a session key.

public static byte[] CreateSessionKey()

Returns

byte[]

DecryptString(string, byte[])

public static string DecryptString(string source, byte[] password)

Parameters

NameTypeDescription
source string
password byte[]

Returns

string

DecryptStringToSecureString(string, byte[])

public static SecureString DecryptStringToSecureString(string source, byte[] password)

Parameters

NameTypeDescription
source string
password byte[]

Returns

SecureString

DecryptStringToString(string, byte[])

public static string DecryptStringToString(string source, byte[] password)

Parameters

NameTypeDescription
source string
password byte[]

Returns

string

DecryptV3Data(byte[], byte[])

Decrypt data encrypted using Blowfish in version 3

public static string DecryptV3Data(byte[] source, byte[] key)

Parameters

NameTypeDescription
source byte[]
key byte[]

Returns

string

DecryptV3Data(string, byte[])

public static string DecryptV3Data(string source, byte[] key)

Parameters

NameTypeDescription
source string
key byte[]

Returns

string

EncryptDataWithPublicKey(byte[], string)

Encrypts data using the specified RSA public key.

public static byte[] EncryptDataWithPublicKey(byte[] source, string keyXML)

Parameters

NameTypeDescription
source byte[]
keyXML string

Returns

byte[]

EncryptString(SecureString, byte[])

public static string EncryptString(SecureString source, byte[] password)

Parameters

NameTypeDescription
source SecureString
password byte[]

Returns

string

EncryptString(string, byte[])

Encrypts a string.

public static string EncryptString(string source, byte[] password)

Parameters

NameTypeDescription
source string
password byte[]

Returns

string

The encrypted value plus the salt value used in encryption.

Remarks

The return value has the format salt:encrypted_data where both the sale and encrypted_data are base-64 encoded.

EncryptString(string, byte[], byte[])

public static string EncryptString(string source, byte[] password, byte[] ivBytes)

Parameters

NameTypeDescription
source string
password byte[]
ivBytes byte[]

Returns

string

GetRandomBytes(int)

Creates a random encryption key suitable for use by the encryption/decryption methods in this class.

public static byte[] GetRandomBytes(int length)

Parameters

NameTypeDescription
length int

Returns

byte[]

ReEncryptStringToString(string, byte[], byte[])

public static string ReEncryptStringToString(string source, byte[] sourcePW, byte[] targetPW)

Parameters

NameTypeDescription
source string
sourcePW byte[]
targetPW byte[]

Returns

string