Ejemplo n.º 1
0
        public void WriteTo(NetworkStream stream, EncryptionRSA rsa)
        {
            string msg = Header + LINE_SEPARATOR + Body + LINE_SEPARATOR;

            byte[] data = rsa.Encrypt(Encoding.ASCII.GetBytes(msg));
            //encrypt data using public key
            stream.Write(data, 0, data.Length);
        }
Ejemplo n.º 2
0
        public void ReadFrom(NetworkStream stream, EncryptionRSA rsa)
        {
            byte[] bytes = new byte[10024];
            int    count = stream.Read(bytes, 0, 10024);

            byte[] descripted = new byte[count];
            for (int i = 0; i < count; i++)
            {
                descripted[i] = bytes[i];
            }

            string msg = rsa.Decrypt(descripted);

            this.Header = msg.Split(';')[0];
            this.Body   = msg.Split(';')[1];
        }