I am writing a program for a class that does simple RSA encryption and decryption. The numbers generated when the program runs one instance is as follows:
encryption:
p = 37
q = 11
n = 407
phi = 360
e = 17
d = 24
Enter the message you wish to encrypt: hello
ASCII: 104
ASCII: 101
ASCII: 108
ASCII: 108
ASCII: 111
Here is your encrypted message:
:Žřřo
decryption:
Enter in a value for n:407
Enter in a value for d:24
Enter the message you wish to decrypt::Žřřo
ASCII: 158
ASCII: 223
ASCII: 47
ASCII: 47
ASCII: 111
Here is your decrypted message:
ß//o
My question is, why does this not give me back the correct ASCII values after decryption? All of the rules for RSA are met:
1. p and q are separate prime numbers
2. e and phi are coprime
3. d is the modular multiplicative inverse of e such that e * d mod n = 1
The program randomly generates p, q, and e and calculates n, phi, and d each time it runs. Other examples have been similar, with all RSA rules met and still not getting the right decryption.