Esempio n. 1
0
        private void buttSend_Click(object sender, EventArgs e)
        {
            try
            {
                System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                byte[] msg = new byte[1500];
                msg = enc.GetBytes(TextMessBoxC1.Text);
                //send the message to other client
                sck.Send(msg);
                items.Add(" You: " + TextMessBoxC1.Text);
                listBoxClient1.DataSource = null;

                listBoxClient1.DataSource = items;

                //listBoxClient1.Items.Add("You: " + TextMessBoxC1.Text);
                TextMessBoxC1.Clear();
            }

            catch (Exception exp)

            {
                textBoxEMessage.Text = "You need to connect first";
                MessageBox.Show(exp.ToString());
                textBoxEMessage.Clear();
            }
        }
Esempio n. 2
0
        private void buttCrypSend_Click(object sender, EventArgs e)
        {
            // EXAMPLE
            //string plainText = "The quick brown fox jumped over the lazy dog.";

            //string cipherText = blowFish.Encrypt_CBC(plainText);
            //MessageBox.Show(cipherText);

            //plainText = blowFish.Decrypt_CBC(cipherText);
            //MessageBox.Show(plainText);

            //System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
            ////byte[] msg = new byte[1500];
            //msg = enc.GetBytes(TextMessBoxC1.Text);
            ////send the message to other client
            //sck.Send(msg);
            //items.Add(" You: " + TextMessBoxC1.Text);
            //listBoxClient1.DataSource = null;

            //listBoxClient1.DataSource = items;
            try
            {
                System.Text.ASCIIEncoding encode = new System.Text.ASCIIEncoding();
                byte[] msg = new byte[1500];
                //msg = encode.GetBytes(TextMessBoxC1.Text);
                string hmsg      = TextMessBoxC1.Text;
                string encrypted = blowFish.Encrypt_CBC(hmsg);
                msg = encode.GetBytes(encrypted);
                //send the message to other client

                sck.Send(msg);
                items.Add(" You: " + TextMessBoxC1.Text);
                listBoxClient1.DataSource = null;

                listBoxClient1.DataSource = items;

                //listBoxClient1.Items.Add("You: " + TextMessBoxC1.Text);
                TextMessBoxC1.Clear();
            }

            catch (Exception exp)

            {
                textBoxEMessage.Text = "You need to connect first";
                MessageBox.Show(exp.ToString());
                textBoxEMessage.Clear();
            }
        }