/// <summary> /// Decrypts the specified stream using Private key. /// </summary> public override void Decrypt(Stream cipherStream, Stream outputStream, IPrivateKey privateKey) { try { using (var cipher = new VirgilChunkCipher()) using (var source = new VirgilStreamDataSource(cipherStream)) using (var sink = new VirgilStreamDataSink(outputStream)) { cipher.DecryptWithKey(source, sink, privateKey.Get().ReceiverId, privateKey.Get().Value); } } catch (Exception ex) { throw new CryptoException(ex.Message); } }
/// <summary> /// Encrypts the specified stream using recipients Public keys. /// </summary> public override void Encrypt(Stream inputStream, Stream cipherStream, params IPublicKey[] recipients) { try { using (var cipher = new VirgilChunkCipher()) using (var source = new VirgilStreamDataSource(inputStream)) using (var sink = new VirgilStreamDataSink(cipherStream)) { foreach (var publicKey in recipients) { cipher.AddKeyRecipient(publicKey.Get().ReceiverId, publicKey.Get().Value); } cipher.Encrypt(source, sink); } } catch (Exception ex) { throw new CryptoException(ex.Message); } }