public static string DecryptString(string EncryptedText, string iv = "", string key = "") { try { iv = (iv + Röschti).Substring(0, 16); key = (key + Bradwurscht).Substring(0, 32); byte[] encryptedTextBytes = Convert.FromBase64String(EncryptedText); System.Security.Cryptography.SymmetricAlgorithm rijn = SymmetricAlgorithm.Create(); MemoryStream ms = new MemoryStream(); byte[] ba_rgbIV = Encoding.ASCII.GetBytes(iv); byte[] ba_key = Encoding.ASCII.GetBytes(key); CryptoStream cs = new CryptoStream(ms, rijn.CreateDecryptor(ba_key, ba_rgbIV), CryptoStreamMode.Write); cs.Write(encryptedTextBytes, 0, encryptedTextBytes.Length); cs.Close(); rijn.Dispose(); rijn = null; return(Encoding.UTF8.GetString(ms.ToArray())); } catch (Exception) { return(null); } }
/// <summary> /// Releases all resources used by the current instance of the /// <see cref="SymmetricEncryptor"/> class. /// </summary> public void Dispose() { _algorithm.Dispose(); }
public void Dispose() { decryptor.Dispose(); encryptor.Dispose(); aes.Dispose(); }