Table of Contents

Class CryptHelper2

Namespace
SunamoCrypt
Assembly
SunamoCrypt.dll

Cryptographic helper class with various encryption algorithms

public class CryptHelper2
Inheritance
CryptHelper2
Inherited Members
Extension Methods

Fields

EncryptedTextIsAnInvalidLength

Error message for invalid encrypted text length

public static string EncryptedTextIsAnInvalidLength

Field Value

string

InitializationVectorRc2

Initialization vector for RC2 encryption

public static List<byte>? InitializationVectorRc2

Field Value

List<byte>

InitializationVectorRijndael

Initialization vector for Rijndael encryption

public static List<byte>? InitializationVectorRijndael

Field Value

List<byte>

InitializationVectorTripleDes

Initialization vector for TripleDES encryption

public static List<byte>? InitializationVectorTripleDes

Field Value

List<byte>

Passphrase

Passphrase for encryption (must be set before using convenience methods)

public static string? Passphrase

Field Value

string

Salt16

16-byte salt for encryption (must be set before using convenience methods)

public static List<byte>? Salt16

Field Value

List<byte>

Methods

DecryptRC2(List<byte>)

Decrypts RC2-encrypted data using pre-configured settings

public static List<byte> DecryptRC2(List<byte> cipherTextBytes)

Parameters

cipherTextBytes List<byte>

Encrypted data to decrypt

Returns

List<byte>

Decrypted data

DecryptRC2(List<byte>, string, List<byte>, List<byte>)

Decrypts RC2-encrypted data

public static List<byte> DecryptRC2(List<byte> cipherTextBytes, string passPhrase, List<byte> saltValueBytes, List<byte> initVectorBytes)

Parameters

cipherTextBytes List<byte>

Encrypted data to decrypt

passPhrase string

Passphrase for key derivation

saltValueBytes List<byte>

Salt value for key derivation

initVectorBytes List<byte>

Initialization vector

Returns

List<byte>

Decrypted data

DecryptRC2(string)

Decrypts RC2-encrypted text using pre-configured settings

public static string DecryptRC2(string text)

Parameters

text string

Encrypted text to decrypt

Returns

string

Decrypted text

DecryptRSA(List<byte>, string, int)

Decrypts RSA-encrypted data

public static Task<List<byte>> DecryptRSA(List<byte> cipherTextBytes, string xmlKeyFile, int keySize)

Parameters

cipherTextBytes List<byte>

Encrypted data to decrypt

xmlKeyFile string

Path to XML file containing RSA key

keySize int

RSA key size in bits

Returns

Task<List<byte>>

Decrypted data

DecryptRSA(string, int, string)

Decrypts RSA-encrypted text

public static string DecryptRSA(string text, int keySize, string xmlString)

Parameters

text string

Encrypted text to decrypt

keySize int

RSA key size in bits

xmlString string

XML string containing RSA key

Returns

string

Decrypted text

DecryptRijndael(List<byte>)

Decrypts Rijndael-encrypted data using pre-configured settings

public static List<byte> DecryptRijndael(List<byte> cipherTextBytes)

Parameters

cipherTextBytes List<byte>

Encrypted data to decrypt

Returns

List<byte>

Decrypted data

DecryptRijndael(List<byte>, List<byte>)

Decrypts Rijndael-encrypted data with custom salt

public static List<byte> DecryptRijndael(List<byte> cipherTextBytes, List<byte> salt)

Parameters

cipherTextBytes List<byte>

Encrypted data to decrypt

salt List<byte>

Salt value for decryption

Returns

List<byte>

Decrypted data

DecryptRijndael(List<byte>, string, List<byte>, List<byte>)

Decrypts Rijndael-encrypted data

public static List<byte> DecryptRijndael(List<byte> cipherTextBytes, string passPhrase, List<byte> saltValueBytes, List<byte> initVectorBytes)

Parameters

cipherTextBytes List<byte>

Encrypted data to decrypt

passPhrase string

Passphrase for key derivation

saltValueBytes List<byte>

Salt value for key derivation

initVectorBytes List<byte>

Initialization vector

Returns

List<byte>

Decrypted data

Remarks

Uses A1 hash algorithm, 128-bit key size, and 2 password iterations (hardcoded internally). All parameters must match those used during encryption.

DecryptRijndael(string)

Decrypts Rijndael-encrypted text using pre-configured settings

public static string DecryptRijndael(string text)

Parameters

text string

Encrypted text to decrypt

Returns

string

Decrypted text

DecryptRijndael(string, List<byte>)

Decrypts Rijndael-encrypted text with custom salt

public static string DecryptRijndael(string plainText, List<byte> salt)

Parameters

plainText string

Encrypted text to decrypt

salt List<byte>

Salt value for decryption

Returns

string

Decrypted string

DecryptTripleDES(List<byte>)

Decrypts TripleDES-encrypted data using pre-configured settings

public static List<byte> DecryptTripleDES(List<byte> cipherTextBytes)

Parameters

cipherTextBytes List<byte>

Encrypted data to decrypt

Returns

List<byte>

Decrypted data

DecryptTripleDES(List<byte>, string, List<byte>, List<byte>)

Decrypts TripleDES-encrypted data

public static List<byte> DecryptTripleDES(List<byte> cipherTextBytes, string passPhrase, List<byte> saltValueBytes, List<byte> initVectorBytes)

Parameters

cipherTextBytes List<byte>

Encrypted data to decrypt

passPhrase string

Passphrase for key derivation

saltValueBytes List<byte>

Salt value for key derivation

initVectorBytes List<byte>

Initialization vector

Returns

List<byte>

Decrypted data

DecryptTripleDES(string)

Decrypts TripleDES-encrypted text using pre-configured settings

public static string DecryptTripleDES(string cipherText)

Parameters

cipherText string

Encrypted text to decrypt

Returns

string

Decrypted text

EncryptRC2(List<byte>)

Encrypts data using RC2 algorithm with pre-configured settings

public static List<byte> EncryptRC2(List<byte> plainTextBytes)

Parameters

plainTextBytes List<byte>

Data to encrypt

Returns

List<byte>

Encrypted data

EncryptRC2(List<byte>, string, List<byte>, List<byte>)

Encrypts data using RC2 algorithm

public static List<byte> EncryptRC2(List<byte> plainTextBytes, string passPhrase, List<byte> saltValueBytes, List<byte> initVectorBytes)

Parameters

plainTextBytes List<byte>

Data to encrypt

passPhrase string

Passphrase for key derivation

saltValueBytes List<byte>

Salt value for key derivation

initVectorBytes List<byte>

Initialization vector

Returns

List<byte>

Encrypted data

EncryptRC2(string)

Encrypts text using RC2 algorithm with pre-configured settings

public static string EncryptRC2(string text)

Parameters

text string

Text to encrypt

Returns

string

Encrypted text

EncryptRSA(List<byte>, string, int)

Encrypts data using RSA algorithm

public static Task<List<byte>> EncryptRSA(List<byte> plainTextBytes, string xmlKeyFile, int keySize)

Parameters

plainTextBytes List<byte>

Data to encrypt

xmlKeyFile string

Path to XML file containing RSA key

keySize int

RSA key size in bits

Returns

Task<List<byte>>

Encrypted data

EncryptRSA(string, int, string)

Encrypts text using RSA algorithm

public static string EncryptRSA(string text, int keySize, string xmlString)

Parameters

text string

Text to encrypt

keySize int

RSA key size in bits

xmlString string

XML string containing RSA key

Returns

string

Encrypted text as base64 string

EncryptRijndael(List<byte>)

Encrypts data using Rijndael algorithm with pre-configured settings

public static List<byte> EncryptRijndael(List<byte> plainTextBytes)

Parameters

plainTextBytes List<byte>

Data to encrypt

Returns

List<byte>

Encrypted data

EncryptRijndael(List<byte>, List<byte>)

Encrypts data using Rijndael algorithm with custom salt

public static List<byte> EncryptRijndael(List<byte> plainTextBytes, List<byte> salt)

Parameters

plainTextBytes List<byte>

Data to encrypt

salt List<byte>

Salt value for encryption

Returns

List<byte>

Encrypted data

EncryptRijndael(List<byte>, string, List<byte>, List<byte>)

Encrypts data using Rijndael symmetric key algorithm

public static List<byte> EncryptRijndael(List<byte> plainTextBytes, string passPhrase, List<byte> saltValueBytes, List<byte> initVectorBytes)

Parameters

plainTextBytes List<byte>

Data to encrypt

passPhrase string

Passphrase for key derivation

saltValueBytes List<byte>

Salt value for key derivation

initVectorBytes List<byte>

Initialization vector

Returns

List<byte>

Encrypted data

Remarks

Uses A1 hash algorithm, 128-bit key size, and 2 password iterations (hardcoded internally)

EncryptRijndael(string)

Encrypts text using Rijndael algorithm with pre-configured settings

public static string EncryptRijndael(string text)

Parameters

text string

Text to encrypt

Returns

string

Encrypted text

EncryptTripleDES(List<byte>)

Encrypts data using TripleDES with pre-configured settings

public static List<byte> EncryptTripleDES(List<byte> plainTextBytes)

Parameters

plainTextBytes List<byte>

Data to encrypt

Returns

List<byte>

Encrypted data

EncryptTripleDES(List<byte>, string, List<byte>, List<byte>)

Encrypts data using TripleDES algorithm

public static List<byte> EncryptTripleDES(List<byte> plainTextBytes, string passPhrase, List<byte> saltValueBytes, List<byte> initVectorBytes)

Parameters

plainTextBytes List<byte>

Data to encrypt

passPhrase string

Passphrase for key derivation

saltValueBytes List<byte>

Salt value for key derivation

initVectorBytes List<byte>

Initialization vector

Returns

List<byte>

Encrypted data

EncryptTripleDES(string)

Encrypts text using TripleDES with pre-configured settings

public static string EncryptTripleDES(string text)

Parameters

text string

Text to encrypt

Returns

string

Encrypted text

GetRSAParametersFromXml(string)

Loads RSA parameters from XML file

public static RSAParameters GetRSAParametersFromXml(string xmlFilePath)

Parameters

xmlFilePath string

Path to XML file containing RSA parameters

Returns

RSAParameters

RSA parameters