RSA 加密数字不起作用,为什么?

RSA encryption numbers not working, why?

我正在为 class 编写一个程序,它可以进行简单的 RSA 加密和解密。程序运行一个实例时生成的数字如下:

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

我的问题是,为什么这在解密后没有返回正确的 ASCII 值?满足 RSA 的所有规则:
1. p和q是独立的质数
2. e和phi互质
3. d 是 e 的 mod 元乘法逆元,满足 e * d mod n = 1

程序随机生成 p、q 和 e,并在每次运行时计算 n、phi 和 d。其他示例也类似,满足所有 RSA 规则但仍未获得正确的解密。

也许这只是您问题中的错字,但我认为 d 应该是 ephi(n) 的乘法逆,而不是 n.