System.Security.Cryptography.RijndaelManaged.CreateDecryptor C# (CSharp) Method

CreateDecryptor() public method

public CreateDecryptor ( ) : ICryptoTransform
return ICryptoTransform
        public override ICryptoTransform CreateDecryptor() => _impl.CreateDecryptor();
        public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV) => _impl.CreateDecryptor(rgbKey, rgbIV);

Same methods

RijndaelManaged::CreateDecryptor ( byte rgbKey, byte rgbIV ) : ICryptoTransform

Usage Example

示例#1
1
        /// <summary>
        /// Decrypts the specified data using a 128-bit cipher. The key can be any length.
        /// </summary>
        /// <param name="Data">The data to be decrypted.</param>
        /// <param name="Key">The key used to decrypt the data.</param>
        /// <returns>A string containing the decoded data.</returns>
        public static byte[] Decrypt128Byte(byte[] Data, byte[] Key)
        {
            RijndaelManaged AES = null;
            var MS = new MemoryStream(Data);
            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 RijndaelManaged { BlockSize = 128, KeySize = 128, Key = KeyData.Key, IV = KeyData.IV, Mode = CipherMode.CBC, Padding = PaddingMode.PKCS7 };
                CS = new CryptoStream(MS, AES.CreateDecryptor(), CryptoStreamMode.Read);
                DS = new StreamReader(CS);

                var D = new byte[CS.Length];
                CS.Read(D, 0, (int)CS.Length - 1);
                return D;
            }
            finally
            {
                if (AES != null) AES.Clear();
                MS.Dispose();
                if (CS != null) CS.Dispose();
                if (DS != null) DS.Dispose();
            }
        }
All Usage Examples Of System.Security.Cryptography.RijndaelManaged::CreateDecryptor