A class to assist in Encrypting and Decrypting data.
public class Encrypter
public string Encrypt(string valueToEncrypt)
Encrypt a value.
The string value to encyrpt.
public string Encrypt(string valueToEncrypt, byte[] key, byte[] iv)
Encrypt a value with passed in key and seed.
The string value to encyrpt.
The key to use to encrypt.
The seed used in encrypting.
public string Decrypt(string encryptedValue)
Decrypt a value.
The string value to decyrpt.
public string Decrypt(string encryptedValue, byte[] key, byte[] iv)
Decrypt a value with passed in key and seed.
The string value to decyrpt.
The key to use to decyrpt.
The seed used in decrypting.
public string ReEncrypt(string valueToReEncrypt, byte[] newKey, byte[] newIv)
Decrypt a value and then ReEncrypt the value with passed in key and seed.
The string value to decyrpt.
The key to use to encrypt.
The seed used in encrypting.
public string ReEncrypt(string valueToReEncrypt, byte[] newKey, byte[] newIv,
byte[] oldKey, byte[] oldIv)
Decrypt a value and then ReEncrypt the value with passed in key and seed.
The string value to decyrpt.
The key to use to encrypt.
The seed used in encrypting.
The key to use to decrypt.
The seed used in decrypting.
public byte[] GenerateKey()
Randomly generate a new key to use with encrypting. This can be used with the Encrypt above without specifying a key.
public byte[] GenerateIV()
Randomly generate a new seed to use with encrypting. This can be used with the Encrypt above without specifying an iv.
public List<byte[]> SplitKey(byte[] key, int numberOfParts)
Split a key into a designated number of parts to be stored in different locations. This prevents key theft as all key parts are required to be able to recombine and use.
The key or iv value to split into a list of parts.
The number of byte arrays to create to from this key.
public byte[] CombineKeys(List<byte[]> keyParts)
Combine a list of split keys back into the orignal key value.
The list of split key or iv values to recombine again.
var enc = new Encrypter();var key = enc.GenerateKey();var iv = enc.GenerateIV();var x = enc.Encrypt();