Ejemplo n.º 1
0
        public void Recv()
        {
            Action <string> Show_Recv = new Action <string>(RecvboxFresh);

            while (true)
            {
                tmp = PUB.s.Receive(bytesReceived, bytesReceived.Length, 0);
                byte[] cipherbyte = new byte[tmp];
                Array.Copy(bytesReceived, 0, cipherbyte, 0, tmp);
                byte[] plainbytes = AES_module.AES_Decrypt(cipherbyte, AES_Key, AES_IV);
                string plaintext  = Encoding.UTF8.GetString(plainbytes);
                Invoke(Show_Recv, plaintext);
            }
        }
Ejemplo n.º 2
0
        private void Recv()
        {
            Action <string> Show_Recv = new Action <string>(RecvboxFresh);

            try
            {
                while (true)
                {
                    counter = PUB.s_chat.Receive(bytesReceived, bytesReceived.Length, 0);
                    byte[] cipherbyte = new byte[counter];
                    Array.Copy(bytesReceived, 0, cipherbyte, 0, counter);
                    byte[] plainbytes = AES_module.AES_Decrypt(cipherbyte, PUB.AES_Key, PUB.AES_IV);
                    string plaintext  = Encoding.UTF8.GetString(plainbytes);
                    Invoke(Show_Recv, plaintext);
                }
            }
            catch (SocketException e)
            {
            }
        }