/// <summary> /// Read encrypted data from an input stream and write the decrypted data to an output stream /// </summary> /// <param name="cipher">The <see cref="ICipher"/> to use for decrypting the data</param> /// <param name="input">The input stream containing encrypted data to read from</param> /// <param name="output">The output stream to write the decrypted data to</param> /// <remarks>This method leaves both the <paramref name="input"/> and <paramref name="output"/> streams open</remarks> public static async Task DecryptAsync(this ICipher cipher, Stream input, Stream output) { using (var cryptoStream = cipher.CreateDecryptionStream(input, CryptoStreamMode.Read, true)) await cryptoStream.CopyToAsync(output).ConfigureAwait(false); }
/// <summary> /// Read encrypted data from an input stream and write the decrypted data to an output stream /// </summary> /// <param name="cipher">The <see cref="ICipher"/> to use for decrypting the data</param> /// <param name="input">The input stream containing encrypted data to read from</param> /// <param name="output">The output stream to write the decrypted data to</param> /// <remarks>This method leaves both the <paramref name="input"/> and <paramref name="output"/> streams open</remarks> public static void Decrypt(this ICipher cipher, Stream input, Stream output) { using (var cryptoStream = cipher.CreateDecryptionStream(input, CryptoStreamMode.Read, true)) cryptoStream.CopyTo(output); }