Ejemplo n.º 1
0
        void Receive()
        {
            NetworkStream networkStream = new NetworkStream(this.ClientSocket);

            while (true)
            {
                Postman postMan = Postman.GetPackage(networkStream);
                Console.WriteLine(postMan);
                switch (postMan.Type)
                {
                case Postman.PostmanType.SEND_KEY:
                    this.ServerMysterio.PubKey = Mysterio.ConvertBytesToKey(postMan.Payload);
                    break;

                case Postman.PostmanType.SEND_MESSAGE:
                    string plainText = Mysterio.Decrypt(this.ClientMysterio.PriKey, postMan.Payload);
                    Console.WriteLine(plainText);
                    break;
                }
                if (postMan.Type == Postman.PostmanType.DISCONNECT)
                {
                    break;
                }
            }
            networkStream.Close();
        }
Ejemplo n.º 2
0
        void Send()
        {
            NetworkStream networkStream = new NetworkStream(this.ClientSocket);

            while (true)
            {
                string  str     = Console.ReadLine();
                Postman postMan = new Postman();

                switch (str.ToUpper())
                {
                case "SEND_KEY":
                    postMan.Type    = Postman.PostmanType.SEND_KEY;
                    postMan.Payload = Mysterio.ConvertKeyToBytes(this.ClientMysterio.PubKey);
                    break;

                default:
                    postMan.Type    = Postman.PostmanType.SEND_MESSAGE;
                    postMan.Payload = Mysterio.Encrypt(this.ServerMysterio.PubKey, str);
                    break;
                }

                Postman.SendPackage(networkStream, postMan);
                if (str.ToUpper().Equals("QUIT"))
                {
                    break;
                }
            }

            networkStream.Close();
        }
Ejemplo n.º 3
0
        public Message carryOut()
        {
            MiddlewareService.Message msg = messenger.writeMessage();
            Postman postman = new Postman();

            return(postman.sendMessage(msg));
        }