예제 #1
0
        private void inputPrimes()
        {
            if (numbersChanged)
            {
                generated = false;
                checkText(textBoxP.Text, true);
                checkText(textBoxQ.Text, false);

                if (isPrimeP && isPrimeQ)
                {
                    this.primesPair = new PrimesPair(Int32.Parse(textBoxP.Text), Int32.Parse(textBoxQ.Text));
                    generateKeyPair();
                    numbersChanged = false;
                }
            }
        }
예제 #2
0
        private void generatePrimesPair()
        {
            Random rnd   = new Random();
            long   maxPQ = (long)Math.Pow(27.0, (double)numericL.Value / 2.0);
            long   minPQ = (long)Math.Pow(27.0, (double)numericK.Value / 2.0);

            long P, Q;

            do
            {
                P = LongRandom(minPQ, maxPQ, rnd);
            } while (!isPrime(P));

            do
            {
                Q = LongRandom(minPQ, maxPQ, rnd);
            } while (!isPrime(Q) || P == Q);

            this.primesPair = new PrimesPair(P, Q);
            generated       = false;
            isPrimeP        = isPrimeQ = true;
            numbersChanged  = false;
        }