System.Utilities.Cryptography.Encryption.Decrypt256String C# (CSharp) Method

Decrypt256String() public static method

Decrypts the specified data using a 256-bit cipher. The key can be any length.
public static Decrypt256String ( Stream Data, byte Key ) : string
Data Stream The data to be decrypted.
Key byte The key used to decrypt the data.
return string
        public static string Decrypt256String(Stream Data, byte[] Key)
        {
            AesCryptoServiceProvider AES = null;
            CryptoStream CS = null;
            StreamReader DS = null;
            try
            {
                //Get the IV and length corrected Key.
                KeyData KeyData = GenerateKeyIV128(Key);
                //Create the AES crytpograhy object.
                AES = new AesCryptoServiceProvider { BlockSize = 256, KeySize = 256, Key = KeyData.Key, IV = KeyData.IV, Mode = CipherMode.CBC, Padding = PaddingMode.PKCS7 };
                CS = new CryptoStream(Data, AES.CreateDecryptor(), CryptoStreamMode.Read);
                DS = new StreamReader(CS);

                return DS.ReadToEnd();
            }
            finally
            {
                if (AES != null) AES.Clear();
                if (CS != null) CS.Dispose();
                if (DS != null) DS.Dispose();
            }
        }

Same methods

Encryption::Decrypt256String ( byte Data, byte Key ) : string