Ejemplo n.º 1
0
        //Alice Nhận public_key Từ Bob --> Tạo Key Chung
        public void receive_key_public(string[] mess)
        {
            SHA256 sha256 = SHA256Managed.Create();

            dh.Tao_key_chung(Convert.ToInt32(mess[1]));
            key         = sha256.ComputeHash(Encoding.ASCII.GetBytes(Convert.ToString(dh.Key_Chung)));
            txtkey.Text = Convert.ToBase64String(key);
            session     = true;
        }
Ejemplo n.º 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;
        }