Example #1
0
        static void Main(string[] args)
        {
            WebChaffEncoder Encoder = new WebChaffEncoder();

            while (true)
            {
                String userText;
                string MacString = "";
                string EncodedMessage;
                char[] arraySplit = { ' ' };
                Console.WriteLine("\nFaraz:");



                userText = Console.ReadLine();

                System.DateTime startTime = System.DateTime.Now;
                EncodedMessage = Encoder.EncodeMessage(userText.Split(arraySplit), out MacString);
                Console.WriteLine("\nEncodedTo:" + EncodedMessage);
                Console.WriteLine("\n MacString is:" + MacString);
                System.DateTime stopTime = System.DateTime.Now;
                Console.WriteLine("\nDecoded Message:" + Encoder.DecodeMessage(EncodedMessage, MacString));

                TimeSpan duration = stopTime - startTime;
                Console.WriteLine("Encoding time:" + duration);
            }
        }
Example #2
0
        private void InitializeConnection()
        {
            Encoder = new WebChaffEncoder();
            // Parse the IP address from the TextBox into an IPAddress object
            ipAddr = IPAddress.Parse(txtIp.Text);
            // Start a new TCP connections to the chat server
            tcpServer = new TcpClient();
            tcpServer.Connect(ipAddr, 1986);

            // Helps us track whether we're connected or not
            Connected = true;
            // Prepare the form
            UserName = txtUser.Text;

            // Disable and enable the appropriate fields
            txtIp.Enabled      = false;
            txtUser.Enabled    = false;
            txtMessage.Enabled = true;
            btnSend.Enabled    = true;
            btnConnect.Text    = "Disconnect";

            // Send the desired username to the server
            swSender = new StreamWriter(tcpServer.GetStream());
            swSender.WriteLine(txtUser.Text);
            swSender.Flush();

            // Start the thread for receiving messages and further communication
            thrMessaging = new Thread(new ThreadStart(ReceiveMessages));
            thrMessaging.Start();
        }