Ejemplo n.º 1
0
        /// <summary>
        /// Close ket noi hien tai
        /// </summary>


        /// <summary>
        /// Send Message
        /// </summary>
        void Send(Socket client)
        {
            dateTimeIV = md5.maHoaMd5(DateTime.Now.ToString());
            string time = dateTimeIV.Substring(0, 16);

            dateTimeIv = Encoding.UTF8.GetBytes(time);
            string a = txbSecretkey.Text.Substring(0, 32);

            byte[] key = Encoding.ASCII.GetBytes(a);
            string s   = aes.EncryptString(txtMessage.Text, key, dateTimeIv);

            byte[] mahoa      = diff.MaHoaDiffie(nhankey, s);
            byte[] dodai      = BitConverter.GetBytes(mahoa.Length);
            byte[] initvector = diff.IV;
            if (client != null && txtMessage.Text != string.Empty)
            {
                client.Send(dodai);
                client.Send(mahoa);
                client.Send(initvector);
            }
        }
        void Send(Socket client)
        {
            dateTimeIV = md5.maHoaMd5(DateTime.Now.ToString());
            string time = dateTimeIV.Substring(0, 16);

            dateTimeIv = Encoding.UTF8.GetBytes(time);
            string a = textBox4.Text.Substring(0, 32);

            byte[] key           = Encoding.ASCII.GetBytes(a);
            int    paddingValue  = AddPadding();
            string _paddingValue = paddingValue.ToString();
            string s             = aes.EncryptString(textBox1.Text + "|" + _paddingValue, key, dateTimeIv);

            byte[] mahoa      = diff.MaHoaDiffie(nhankey, s);
            byte[] dodai      = BitConverter.GetBytes(mahoa.Length);
            byte[] initvector = diff.IV;
            if (client != null && textBox1.Text != string.Empty)
            {
                client.Send(dodai);
                client.Send(mahoa);
                client.Send(initvector);
            }
        }