取模求未知值

Reversing modulo to get unknown value

我正在寻找一种类似于 RSA(不完全相同)的加密算法来解决这个模运算符问题,但我不习惯使用模运算符。

我有四个价值观,这是我发现的最佳价值观。有一条消息、一个密码和两个密钥(public 和私有)。消息 = m,密码 = c,public 密钥 = n,私钥 = e。最后,我将同时拥有密钥和密码,但没有消息。

对于我的原始加密方程,我使用了:

c = (m + e) % n

为了解密,我使用了这个:

m = (c - e) % n

但是当我决定用乘除法代替加减法时,事实证明它并没有那么简单:

c = (m * e) % n
m != (c / e) % n

最后,我想实现第一个结果:

c = (m ** e) % n

总之,我有c = 8 (12)(13), e = 41, n = 63,我知道m = 34,但我不知道如何计算。

8 = (m * 41) % 63
(12 = (m + 41) % 63)
(13 = (m ** 41) % 63)

您要找的算​​法也是extended Euclidean algorithm (there is a pseudocode there) for a mathematical problem of modular multiplicative inverse and it has a question on Computer Science SE