Example #1
0
        //gui key trong tung truong hop tren Hàm receive ở trên
        public void gui_key(string x)
        {
            Tao_p_g();
            dh = new Diffie_hellman(p, g);
            string s = x + ";" + p + ";" + g + ";" + dh.Publickey;

            senddata(s);
        }
Example #2
0
        //Alice Gửi p ,g ,Key Public --> Bob Nhận public_key, p ,g ,private_key random -->Tạo Key Chung
        public void send_key_public(string[] mess)
        {
            SHA256 sha256 = SHA256Managed.Create();

            p  = Convert.ToInt32(mess[1]);
            g  = Convert.ToInt32(mess[2]);
            dh = new Diffie_hellman(p, g);
            dh.Tao_key_chung(Convert.ToInt32(mess[3]));
            key         = sha256.ComputeHash(Encoding.ASCII.GetBytes(Convert.ToString(dh.Key_Chung)));
            txtkey.Text = Convert.ToBase64String(key);
            //Bob Gửi public_key qua Alice
            senddata(Convert.ToString("Receive_Key" + ";" + dh.Publickey));
            session = true;
        }