System.Utilities.Cryptography.Encryption.Decrypt128StringSecure C# (CSharp) Метод

Decrypt128StringSecure() публичный статический Метод

Decrypts the specified data using a 128-bit cipher. The key can be any length.
public static Decrypt128StringSecure ( Stream Data, byte Key ) : System.Security.SecureString
Data Stream The data to be decrypted. Will be converted to UTF8.
Key byte The key used to decrypt the data.
Результат System.Security.SecureString
        public static System.Security.SecureString Decrypt128StringSecure(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 = 128, KeySize = 128, Key = KeyData.Key, IV = KeyData.IV, Mode = CipherMode.CBC, Padding = PaddingMode.PKCS7 };
                CS = new CryptoStream(Data, AES.CreateDecryptor(), CryptoStreamMode.Read);
                DS = new StreamReader(CS);

                var ss = new System.Security.SecureString();
                while (DS.EndOfStream == false)
                    ss.AppendChar(Convert.ToChar(DS.Read()));
                ss.MakeReadOnly();
                return ss;
            }
            finally
            {
                if (AES != null) AES.Clear();
                if (CS != null) CS.Dispose();
                if (DS != null) DS.Dispose();
            }
        }

Same methods

Encryption::Decrypt128StringSecure ( byte Data, byte Key ) : System.Security.SecureString