I am currently preparing for my math exam and the RSA encryption system will be a part of it. But the decryption is quite hard without WolframAlpha or a calculator.
For example I have to decrypt the message $a=3$ which is already encrypted by $e$
The parameter are
- $p=13$
- $q=23$
- $N=pq=13\cdot23=299$
- $\phi(299)=264$
- encryption key $e = 151 $
- decryption key $d=7$
To decrypt $a$ you need to solve the following equation
$$3^7\equiv x \ (mod \ 299)$$
According to Wolfram Alpha the solution is 94. Which theorem can I use for this problem. Little Fermat will not work because 299 isn't a prime number. Calculators aren't allowed in the exam.
By heart, $3^5=243$.
Then mentally $3^6=3\cdot243=729=131\mod299$ (subtract $300$ twice and add $2$).
And $3\cdot131=393=94\mod299$.