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

CreateDecryptor() public method

public CreateDecryptor ( ) : ICryptoTransform
return ICryptoTransform
        public virtual ICryptoTransform CreateDecryptor()
        {
            return CreateDecryptor(Key, IV);
        }

Same methods

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

Usage Example

 private static string Decrypt(byte[] cipher, string passPhrase, string salt, SymmetricAlgorithm algorithm)
 {
     var saltBytes = Encoding.UTF8.GetBytes(salt);
     algorithm.Padding = PaddingMode.None;
     using (algorithm)
     {
         using (var password = new Rfc2898DeriveBytes(passPhrase, saltBytes))
         {
             algorithm.Key = password.GetBytes(algorithm.KeySize / 8);
             algorithm.IV = password.GetBytes(algorithm.BlockSize / 8);
             using (var memStream = new MemoryStream(cipher))
             {
                 using (
                     var cryptoStream = new CryptoStream(memStream, algorithm.CreateDecryptor(),
                                                         CryptoStreamMode.Read))
                 {
                     using (var sr = new StreamReader(cryptoStream))
                     {
                         return sr.ReadToEnd();
                     }
                 }
             }
         }
     }
 }
All Usage Examples Of System.Security.Cryptography.SymmetricAlgorithm::CreateDecryptor