I have given a homework about RSA Encryption, and I have wanted to complete this homework with C Programming Language. By the way, I am trying to find an answer for a problem connected with my code, not only about pow(), so it should not be marked as duplicate question.
int *Encrypt(int* translation, int size){
int chunk;
const int E_RSA = 13;
double N_RSA = 2537;
// some codes...
//formulae = c = m^e mod n
encryptedMessage = fmod(pow(chunk,E_RSA) , N_RSA);
//some codes...
}
So here, when I calculate pow(chunk,E_RSA)
, because my E value is 13, and let's assume that the message is 1900, there will be an operation such as 1900^13, and it will give a huge output. When I calculate it from a calculator, it give a different result from my C code. This difference is being a problem for the encryption. How can I solve it so that the pow() function will return result as precise as a scientific calculator ? Thanks for the help.