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
InitializationVectorRc2
Initialization vector for RC2 encryption
public static List<byte>? InitializationVectorRc2
Field Value
InitializationVectorRijndael
Initialization vector for Rijndael encryption
public static List<byte>? InitializationVectorRijndael
Field Value
InitializationVectorTripleDes
Initialization vector for TripleDES encryption
public static List<byte>? InitializationVectorTripleDes
Field Value
Passphrase
Passphrase for encryption (must be set before using convenience methods)
public static string? Passphrase
Field Value
Salt16
16-byte salt for encryption (must be set before using convenience methods)
public static List<byte>? Salt16
Field Value
Methods
DecryptRC2(List<byte>)
Decrypts RC2-encrypted data using pre-configured settings
public static List<byte> DecryptRC2(List<byte> cipherTextBytes)
Parameters
Returns
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
cipherTextBytesList<byte>Encrypted data to decrypt
passPhrasestringPassphrase for key derivation
saltValueBytesList<byte>Salt value for key derivation
initVectorBytesList<byte>Initialization vector
Returns
DecryptRC2(string)
Decrypts RC2-encrypted text using pre-configured settings
public static string DecryptRC2(string text)
Parameters
textstringEncrypted 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
cipherTextBytesList<byte>Encrypted data to decrypt
xmlKeyFilestringPath to XML file containing RSA key
keySizeintRSA key size in bits
Returns
DecryptRSA(string, int, string)
Decrypts RSA-encrypted text
public static string DecryptRSA(string text, int keySize, string xmlString)
Parameters
textstringEncrypted text to decrypt
keySizeintRSA key size in bits
xmlStringstringXML 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
Returns
DecryptRijndael(List<byte>, List<byte>)
Decrypts Rijndael-encrypted data with custom salt
public static List<byte> DecryptRijndael(List<byte> cipherTextBytes, List<byte> salt)
Parameters
Returns
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
cipherTextBytesList<byte>Encrypted data to decrypt
passPhrasestringPassphrase for key derivation
saltValueBytesList<byte>Salt value for key derivation
initVectorBytesList<byte>Initialization vector
Returns
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
textstringEncrypted 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
Returns
- string
Decrypted string
DecryptTripleDES(List<byte>)
Decrypts TripleDES-encrypted data using pre-configured settings
public static List<byte> DecryptTripleDES(List<byte> cipherTextBytes)
Parameters
Returns
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
cipherTextBytesList<byte>Encrypted data to decrypt
passPhrasestringPassphrase for key derivation
saltValueBytesList<byte>Salt value for key derivation
initVectorBytesList<byte>Initialization vector
Returns
DecryptTripleDES(string)
Decrypts TripleDES-encrypted text using pre-configured settings
public static string DecryptTripleDES(string cipherText)
Parameters
cipherTextstringEncrypted 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
Returns
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
plainTextBytesList<byte>Data to encrypt
passPhrasestringPassphrase for key derivation
saltValueBytesList<byte>Salt value for key derivation
initVectorBytesList<byte>Initialization vector
Returns
EncryptRC2(string)
Encrypts text using RC2 algorithm with pre-configured settings
public static string EncryptRC2(string text)
Parameters
textstringText 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
plainTextBytesList<byte>Data to encrypt
xmlKeyFilestringPath to XML file containing RSA key
keySizeintRSA key size in bits
Returns
EncryptRSA(string, int, string)
Encrypts text using RSA algorithm
public static string EncryptRSA(string text, int keySize, string xmlString)
Parameters
textstringText to encrypt
keySizeintRSA key size in bits
xmlStringstringXML 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
Returns
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
Returns
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
plainTextBytesList<byte>Data to encrypt
passPhrasestringPassphrase for key derivation
saltValueBytesList<byte>Salt value for key derivation
initVectorBytesList<byte>Initialization vector
Returns
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
textstringText 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
Returns
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
plainTextBytesList<byte>Data to encrypt
passPhrasestringPassphrase for key derivation
saltValueBytesList<byte>Salt value for key derivation
initVectorBytesList<byte>Initialization vector
Returns
EncryptTripleDES(string)
Encrypts text using TripleDES with pre-configured settings
public static string EncryptTripleDES(string text)
Parameters
textstringText to encrypt
Returns
- string
Encrypted text
GetRSAParametersFromXml(string)
Loads RSA parameters from XML file
public static RSAParameters GetRSAParametersFromXml(string xmlFilePath)
Parameters
xmlFilePathstringPath to XML file containing RSA parameters
Returns
- RSAParameters
RSA parameters