Пример #1
0
        private void button_Login_Click(object sender, EventArgs e)
        {
            var primeGen = new PrimeNumberGenerator();
            var rnd      = new Random();
            int g        = (int)primeGen.SieveEratosthenes((uint)rnd.Next(3, 20)).Max();
            int p        = (int)primeGen.SieveEratosthenes((uint)rnd.Next(3, 20)).Max();

            DiffieHellman.g = g;
            DiffieHellman.p = p;
            var dhCmd = new ChatCommand
            {
                Type = CommandType.DiffieHellmanInit,
                Data = new DiffieHellmanData
                {
                    g         = g,
                    p         = p,
                    PublicKey = DiffieHellman.MyPublicKey
                }
            };

            richTextBox_Chat.AppendText($"g {DiffieHellman.g}\n");
            richTextBox_Chat.AppendText($"p {DiffieHellman.p}\n");
            richTextBox_Chat.AppendText($"PrivateKey {DiffieHellman.PrivateKey}\n");
            richTextBox_Chat.AppendText($"MyPublicKey {DiffieHellman.MyPublicKey}\n");
            richTextBox_Chat.AppendText($"TheyPublicKey {DiffieHellman.TheyPublicKey}\n");

            controller.SendCommand(dhCmd);
        }
Пример #2
0
        private void ChatForm_Load(object sender, EventArgs e)
        {
            comboBox_Cipher.DataSource = Enum.GetValues(typeof(Cipher));
            richTextBox_Chat.ReadOnly  = true;
            new Thread(controller.Listener)
            {
                IsBackground = true
            }.Start();
            controller.Notify += UpdateMessages;
            var rnd      = new Random();
            var primeGen = new PrimeNumberGenerator();

            DiffieHellman.PrivateKey = (int)primeGen.SieveEratosthenes((uint)rnd.Next(3, 20)).Max();
        }