Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- double prime = 0;
- double root = 0;
- double secretkey = 0;
- double secretkey2 = 0;
- double commonkey = 0;
- double commonkey1 = 0;
- double commonkey2 = 0;
- public Form1()
- {
- InitializeComponent();
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Random random1 = new Random();
- Random random2 = new Random();
- int randomNumber1 = random1.Next(100);
- int randomNumber2 = random2.Next(100);
- prime = Convert.ToDouble(textBox1.Text);
- root = Convert.ToDouble(textBox1.Text);
- secretkey = Math.Pow(root, randomNumber1) % prime;
- secretkey2 = Math.Pow(root, randomNumber2) % prime;
- commonkey1 = Math.Pow(secretkey2, randomNumber1) % prime;
- commonkey2 = Math.Pow(secretkey, randomNumber2) % prime;
- if (commonkey1 == commonkey2)
- {
- commonkey = commonkey1;
- textBox3.Text = "" + commonkey;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment