Class CryptoHelper
Crypto helper.
public static class CryptoHelper
- Inheritance
-
CryptoHelper
- Inherited Members
Methods
CreateSecret(SecureString)
Creates a new Secret from the plain text.
public static Secret CreateSecret(this SecureString plainText)
Parameters
plainText
SecureStringThe plain text.
Returns
CreateSecret(string)
Creates a new Secret from the plain text.
public static Secret CreateSecret(this string plainText)
Parameters
plainText
stringThe plain text.
Returns
CreateSecret(string, Secret)
Creates a new Secret from the plain text.
public static Secret CreateSecret(this string plainText, Secret secret)
Parameters
Returns
CreateSecret(string, byte[], CryptoAlgorithm)
Creates a new Secret from the plain text.
public static Secret CreateSecret(this string plainText, byte[] salt, CryptoAlgorithm algo = null)
Parameters
plainText
stringThe plain text.
salt
byte[]The salt.
algo
CryptoAlgorithmThe hash algorithm.
Returns
Decrypt(byte[], string, byte[], byte[])
Decrypts the cipher text.
public static byte[] Decrypt(this byte[] cipherText, string passPhrase, byte[] salt, byte[] iv)
Parameters
cipherText
byte[]The cipher text.
passPhrase
stringThe pass phrase.
salt
byte[]The salt.
iv
byte[]The iv.
Returns
- byte[]
The decrypted bytes.
DecryptAes(byte[], string, byte[], byte[])
Decrypts the cipher text.
public static byte[] DecryptAes(this byte[] cipherText, string passPhrase, byte[] salt, byte[] iv)
Parameters
cipherText
byte[]The cipher text.
passPhrase
stringThe pass phrase.
salt
byte[]The salt.
iv
byte[]The iv.
Returns
- byte[]
The plain text.
Encrypt(byte[], string, byte[], byte[])
Encrypts the plain text.
public static byte[] Encrypt(this byte[] plain, string passPhrase, byte[] salt, byte[] iv)
Parameters
plain
byte[]The plain text.
passPhrase
stringThe pass phrase.
salt
byte[]The salt.
iv
byte[]The iv.
Returns
- byte[]
The encrypted bytes.
EncryptAes(byte[], string, byte[], byte[])
Encrypts the plain text.
public static byte[] EncryptAes(this byte[] plain, string passPhrase, byte[] salt, byte[] iv)
Parameters
plain
byte[]The plain text.
passPhrase
stringThe pass phrase.
salt
byte[]The salt.
iv
byte[]The iv.
Returns
- byte[]
The cipher text.
FromRsa(RSAParameters)
Converts the RSAParameters to a byte array.
public static byte[] FromRsa(this RSAParameters param)
Parameters
param
RSAParameters
Returns
- byte[]
Byte array.
GenerateRsa()
Returns a new generated
RSAParameters
class which
will be used as a key for the signature.
public static RSAParameters GenerateRsa()
Returns
IsValid(Secret, SecureString)
Validates the password.
public static bool IsValid(this Secret secret, SecureString password)
Parameters
secret
Secretpassword
SecureStringThe password to check.
Returns
- bool
Operation result.
IsValid(Secret, string)
Validates the password.
public static bool IsValid(this Secret secret, string password)
Parameters
Returns
- bool
Operation result.
Md5(byte[])
MD5 hash.
public static string Md5(this byte[] value)
Parameters
value
byte[]The value to hash.
Returns
- string
The hash.
PublicPart(RSAParameters)
Returns the public part of the RSAParameters.
public static RSAParameters PublicPart(this RSAParameters param)
Parameters
param
RSAParameters
Returns
- RSAParameters
The public part of the RSAParameters.
Sha256(byte[])
SHA1 hash.
public static string Sha256(this byte[] value)
Parameters
value
byte[]The value to hash.
Returns
- string
The hash.
Sha512(byte[])
SHA512 hash.
public static string Sha512(this byte[] value)
Parameters
value
byte[]The value to hash.
Returns
- string
The hash.
ToRsa(byte[])
Converts the byte array to RSAParameters.
public static RSAParameters ToRsa(this byte[] key)
Parameters
key
byte[]Byte array.