Ejemplo n.º 1
0
 public UdpRawMessage Decrypt(ICipher cipher)
 {
     CheckDisposed();
     using (var encryptor = cipher.CreateDecryptor())
     {
         this.stream.Position = 0;
         using (CryptoStream cryptoStream = new CryptoStream(new NonDisposableStream(this.stream), encryptor, CryptoStreamMode.Read))
         {
             UdpRawMessage decryptedMessage = new UdpRawMessage(this.memoryStreamPool, (int)this.stream.Length);
             cryptoStream.CopyTo(decryptedMessage.BaseStream);
             decryptedMessage.BaseStream.Position = 0;
             return(decryptedMessage);
         }
     }
 }