public static async Task DecryptAsync(Stream encryptedStream, Stream destinationStream, EncryptionKey key) { using var decryptor = key.CreateDecryptor(encryptedStream); using CryptoStream csDecrypt = new(encryptedStream, decryptor, CryptoStreamMode.Read); await csDecrypt.CopyToAsync(destinationStream).ConfigureAwait(false); }
public static async Task EncryptAsync(Stream sourceStream, Stream destinationStream, EncryptionKey key) { using var encryptor = key.CreateEncryptor(destinationStream); using CryptoStream csEncrypt = new(destinationStream, encryptor, CryptoStreamMode.Write); await sourceStream.CopyToAsync(csEncrypt).ConfigureAwait(false); }