예제 #1
0
        public void Initialize()
        {
            p = PrimeNumberGenerator.Generate();
            q = PrimeNumberGenerator.Generate();

            n = p * q;

            var fi = (p - 1) * (q - 1);

            e       = GetPublicPartKey(fi);
            local_D = GetPrivatePartKey(fi, e);

            _isReady = true;
        }
예제 #2
0
        private long GetPublicPartKey(long fi)
        {
            long e = fi - 1;

            while (true)
            {
                if (PrimeNumberGenerator.IsPrime(e) &&
                    e < fi &&
                    BigInteger.GreatestCommonDivisor(new BigInteger(e), new BigInteger(fi)) == BigInteger.One)
                {
                    break;
                }
                e--;
            }

            return(e);
        }