Exemplo n.º 1
0
        public override Stream GetPayloadStream()
        {
            Stream stream = base.GetPayloadStream();

            cryptor.Encrypt(Payload, 0, Payload.Length);

            byte[] encryptedIV = Utils.ReadFull(cryptor, Payload.Length);
            stream.Write(encryptedIV, 0, encryptedIV.Length);

            return(stream);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public void ReadTest()
        {
            CryptoMemoryStream memoryStream = new CryptoMemoryStream(1024, plainKey);

            byte[] buffer = new byte[data.Length];

            memoryStream.Encrypt(data, 0, data.Length);
            Console.WriteLine(memoryStream.Decrypt(buffer, 0, buffer.Length));
            Console.WriteLine(string.Join(" ", buffer));

            Assert.IsTrue(data.SequenceEqual(buffer));
        }
Exemplo n.º 4
0
        public void WriteTest()
        {
            CryptoMemoryStream memoryStream = new CryptoMemoryStream(1024, plainKey);

            memoryStream.Encrypt(data, 0, data.Length);
        }