Ejemplo n.º 1
0
 /// <summary>
 /// Read cleartext data from an input stream and write the encrypted data to an output stream
 /// </summary>
 /// <param name="cipher">The <see cref="ICipher"/> to use for encrypting the data</param>
 /// <param name="input">The input stream containing cleartext data to read from</param>
 /// <param name="output">The output stream to write the encrypted data to</param>
 /// <remarks>This method leaves both the <paramref name="input"/> and <paramref name="output"/> streams open</remarks>
 public static async Task EncryptAsync(this ICipher cipher, Stream input, Stream output)
 {
     using (var cryptoStream = cipher.CreateEncryptionStream(output, CryptoStreamMode.Write, true))
         await input.CopyToAsync(cryptoStream).ConfigureAwait(false);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Read cleartext data from an input stream and write the encrypted data to an output stream
 /// </summary>
 /// <param name="cipher">The <see cref="ICipher"/> to use for encrypting the data</param>
 /// <param name="input">The input stream containing cleartext data to read from</param>
 /// <param name="output">The output stream to write the encrypted data to</param>
 /// <remarks>This method leaves both the <paramref name="input"/> and <paramref name="output"/> streams open</remarks>
 public static void Encrypt(this ICipher cipher, Stream input, Stream output)
 {
     using (var cryptoStream = cipher.CreateEncryptionStream(output, CryptoStreamMode.Write, true))
         input.CopyTo(cryptoStream);
 }