I am getting this error: System.OverflowException: 'The value is not a number.' I was under the impression that big integer could store any sized value (500 ^ 500 in this case), so I don't understand why this is happening.
public int decode(int code)
{
int totient = (p - 1) * (q - 1);
int d = modInverse(e, totient);
int pq = p * q;
BigInteger decodedMessage = new BigInteger(Math.Pow(code, d) % pq);
return (int)decodedMessage;
}
BigIntegercan, but the result ofMatch.Powis adouble. You need to convertcodetoBigIntegerfirst then doBigInteger.Pow