public override Stream GetPayloadStream() { Stream buffer = base.GetPayloadStream(); byte[] datas = Encoding.UTF8.GetBytes(Payload.ToString()); cryptor.Encrypt(datas, 0, datas.Length); cryptor.Read(datas, 0, datas.Length); buffer.Write(datas, 0, datas.Length); return(buffer); }
public void DuplexRWTest() { CryptoMemoryStream memoryStream = new CryptoMemoryStream(1024, plainKey); byte[] buffer = new byte[data.Length]; for (int i = 0; i < 2; i++) { memoryStream.Encrypt(data, 0, data.Length); Console.WriteLine(memoryStream.Read(buffer, 0, buffer.Length)); Console.WriteLine(string.Join(" ", buffer)); memoryStream.Write(buffer, 0, buffer.Length); memoryStream.Decrypt(buffer, 0, buffer.Length); Assert.IsTrue(data.SequenceEqual(buffer)); } }