public static string Decrypt(byte[] cipherbytes, bool compress) { byte[] buffer = new byte[cipherbytes.Length - 1]; int index = 0; for (int i = 1; i < cipherbytes.Length; i++) { buffer[index++] = cipherbytes[i]; } string decrypted = Obviex.CipherLite.Rijndael.Decrypt(buffer, "this is a pass phrase", null, KEY_SIZE, PASSWORD_ITERATIONS, "this is a salt value", HASH_ALGORITHM); if (cipherbytes[0] == COMPRESSED) { return(CompressionHelper.Inflate(decrypted)); } else { return(decrypted); } }
public static string Encrypt(string plaintext, bool compress) { return(CompressionHelper.BytesToString(Encrypt(CompressionHelper.StringToBytes(plaintext), compress))); }
public static string EncryptToBase64(string plaintext) { byte[] plainBytes = CompressionHelper.StringToBytes(plaintext); byte[] cipherBytes = Encrypt(plainBytes); return(Convert.ToBase64String(cipherBytes)); }
public static string Decrypt(string ciphertext, bool compress) { return(Decrypt(CompressionHelper.StringToBytes(ciphertext), compress)); }