Guest User

sad

a guest
Jan 9th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12. public partial class Form1 : Form
  13. {
  14. double prime = 0;
  15. double root = 0;
  16. double secretkey = 0;
  17. double secretkey2 = 0;
  18. double commonkey = 0;
  19. double commonkey1 = 0;
  20. double commonkey2 = 0;
  21.  
  22. public Form1()
  23. {
  24. InitializeComponent();
  25. }
  26.  
  27. private void textBox1_TextChanged(object sender, EventArgs e)
  28. {
  29.  
  30. }
  31.  
  32. private void button1_Click(object sender, EventArgs e)
  33. {
  34. Random random1 = new Random();
  35. Random random2 = new Random();
  36.  
  37. int randomNumber1 = random1.Next(100);
  38. int randomNumber2 = random2.Next(100);
  39. prime = Convert.ToDouble(textBox1.Text);
  40. root = Convert.ToDouble(textBox1.Text);
  41. secretkey = Math.Pow(root, randomNumber1) % prime;
  42. secretkey2 = Math.Pow(root, randomNumber2) % prime;
  43. commonkey1 = Math.Pow(secretkey2, randomNumber1) % prime;
  44. commonkey2 = Math.Pow(secretkey, randomNumber2) % prime;
  45. if (commonkey1 == commonkey2)
  46. {
  47. commonkey = commonkey1;
  48. textBox3.Text = "" + commonkey;
  49.  
  50.  
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment