Exemplo n.º 1
0
        public static void GeneratePrimeNumber(string begin, string end)
        {
            var beginNumber = BigInteger.Parse(begin);
            var endNumber   = BigInteger.Parse(end);

            for (var i = beginNumber; i < endNumber; i++)
            {
                if (RabinMiler.CheckIfPrimeNumberBignumbers(i, 2))
                {
                    Console.WriteLine(i.ToString() + " ");
                }
            }
        }
Exemplo n.º 2
0
        public static BigInteger GeneratePrimeNumberbyLenght(int primeLenght, int certainty)
        {
            BigInteger primeNumber = BigInteger.One;
            BigInteger iterator    = 2;

            while (primeLenght >= primeNumber.ToString().Length)
            {
                if (primeLenght <= primeNumber.ToString().Length&& RabinMiler.CheckIfPrimeNumberBignumbers(primeLenght, certainty))
                {
                    primeNumber = iterator;
                    Console.WriteLine(primeNumber);
                }
                iterator += 2;
                Console.WriteLine(iterator);
            }
            return(primeNumber);
        }
Exemplo n.º 3
0
        public static BigInteger FastGeneratePrimeNumberbyLenght(int primeBitLenght, int certainty)
        {
            primeBitLenght = primeBitLenght / 8;

            BigInteger primeNumber = RabinMiler.GetRandomPositivOddBigInteger(primeBitLenght);

            BigInteger iterator = primeNumber;

            while (true)
            {
                if (RabinMiler.CheckIfPrimeNumberBignumbers(iterator, certainty))
                {
                    primeNumber = iterator;

                    if (primeBitLenght <= primeNumber.ToByteArray().Length)
                    {
                        break;
                    }
                }
                iterator += 2;
            }
            return(primeNumber);
        }