Esempio n. 1
0
        public DiscreteLogAlgorithmsInfoForm()
        {
            InitializeComponent();
            textBox1.Select(0, 0);
            // textBox2.Select(0, 0);
            base1 = new BigInteger(r.Next(100000) + 2);
            base2 = new BigInteger(r.Next(100000) + 2);
            mod1  = CryptoMath.genSimpleRand(8);
            if (mod1 == base1)
            {
                mod1++;
            }
            mod2 = CryptoMath.genSimpleRand(8);
            if (mod2 == base2)
            {
                mod1++;
            }
            BigInteger rnd1 = CryptoMath.genRand(100000);
            BigInteger rnd2 = CryptoMath.genRand(100000);

            num1            = BigInteger.ModPow(base1, rnd1, mod1);
            num2            = BigInteger.ModPow(base2, rnd2, mod2);
            Task1Label.Text =
                base1.ToString() + "^x  = " + num1.ToString() + " mod " + mod1.ToString();
            Task2Label.Text =
                base2.ToString() + "^x  = " + num2.ToString() + " mod " + mod2.ToString();
        }
Esempio n. 2
0
 private void generatekBtn_Click(object sender, EventArgs e)
 {
     do
     {
         k = CryptoMath.genRand(20);
     } while (k > p - 1);
     kBox.Text = k.ToString();
 }
Esempio n. 3
0
 private void genkBtn_Click(object sender, EventArgs e)
 {
     // matan.DIGITS = 10;
     do
     {
         k = CryptoMath.genRand(10);
     } while (k > p - 1);
     kBox.Text = k.ToString();
 }
Esempio n. 4
0
 private void generatexBtn_Click(object sender, EventArgs e)
 {
     if (p > 2)
     {
         do
         {
             x = CryptoMath.genRand(digits);
         }while (x == 0 || x >= p);
     }
     xtextBox.Text = x.ToString();
 }
        private void RandomDataButton_Click(object sender, EventArgs e)
        {
            Random     rand = new Random();
            int        size = rand.Next(11) + 2;
            BigInteger M    = 0;

            while (!CryptoMath.isPrime((M - 1) / 2))
            {
                M = CryptoMath.genSimpleRand(size);
            }
            MBox.Text = M.ToString();
            ABox.Text = (CryptoMath.genRand(rand.Next(size - 1) + 1) + 2).ToString();
            BBox.Text = (CryptoMath.genRand(rand.Next(size - 1) + 1)).ToString();
        }