Violent Blue
Violent Blue

Reputation: 121

Reversing modulo to get unknown value

I am looking to solve this modulo operator problem for an encryption algorithm similar to RSA (not exactly the same) but I am not used to using the modulo operator.

I have four values as is what I found to be optimal. There is a message, a cypher and two keys (public and private). message = m, cypher = c, public key = n, private key = e. In the end, I will have both keys and the cypher but not the message.

For my original encryption equation, I used:

c = (m + e) % n

For decryption, I used this:

m = (c - e) % n

But it didn't prove as simple when I decided to replace add and subtract with multiply and divide:

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

In the end, I would like to achieve the first result with:

c = (m ** e) % n

In conclusion, I have c = 8 (12)(13), e = 41, n = 63 and I know that m = 34 but I don't know how to calculate it.

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

Upvotes: 1

Views: 257

Answers (1)

sophros
sophros

Reputation: 16690

The algorithm you are looking for is 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 as well

Upvotes: 3

Related Questions