public RSA(BigInteger p, BigInteger q)
{
if (!p.isProbablePrime())
{
throw new Exception("Podana przez Ciebie liczba p prawdopodobnie nie jest liczbą pierwszą!");
}
if (!q.isProbablePrime())
{
throw new Exception("Podana przez Ciebie liczba q prawdopodobnie nie jest liczbą pierwszą!");
}
this.p = p;
this.q = q;
this.n = this.p * this.q;
this.eulerOfN = (this.p - 1) * (this.q - 1);
Random randomGenerator = new Random(DateTime.Now.Millisecond);
do
{
this.e = this.eulerOfN.genCoPrime(randomGenerator.Next(1, this.eulerOfN.bitCount()), randomGenerator);
}
while ((this.e > this.eulerOfN) && this.e.gcd(this.eulerOfN) > 1);
this.d = e.modInverse(eulerOfN);
}