I'm having a hard time creating a functioning RSA algorithm for some reason even though I have all the steps right (or at least I think I do). So I have the following :
I picked prime numbers, p$p$ and q as $q$ as:
p = 13691$$p = 13691$$ q = 29387$$q = 29387$$
I picked n$n$ as p*q$p \cdot q$ n 402337417$$n = 402337417$$
So phi(n) 402294340$$\phi(n) = 402294340$$
I picked a random e$e$ between 1$1$ and phi(n)$\phi(n)$ e 46117$e = 46117$
My message was M=3$M=3$
I got d$d$ by the Extended Euclidean Algorithm as the following: d= 7795$d= 7795$
When I do the encryption using M^e mod n$M^e \,\text{mod}\, n$ I get: c= 399797630$c= 399797630$
When I do the decryption using C^d mod n $C^d \,\text{mod}\, n$, I get 243069037$243069037$, which is not M = 3$M = 3$?
Any idea what can be the reason behind this? myMy guess is that d$d$ is incorrect.