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; }
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); }