I've read a lot about this subject, about Euclidean algorithm, and I have all references needed for this subject right here:
(Best source for my question) -> Math Explanation
Another great example -> Math Explanation 2
Wiki -> Extended Euclidean
Great answer for adding values -> Add Operation
This is where I completely lost it -> AFFINE CIPHERS
However, out of all these sources, I'm still failing to understand how to implement it by code (or pseudo code), or at least find the way to write it.
So I'll write the basics, let's assume I have this formula:
(x * key) % mod = result
0 <= X <= mod
0 <= key <= mod
0 <= result<= mod
key and mod are constants.
* means multiplication operation
% means remainder operation (edited to clarify)
x and result are dynamic.
I want to create a formula that will give me x through code in Java.
The function that calculates result for me is:
private int MultModulus(int num, int key, int mod)
{
return (num * key) % mod;
}
how can I find X? what should I write in order to calculate it? this is the point where I didn't understand, let's assume that my function signature would be:
private int InverseMultModulus(int result, int key, int mod)
{
x = ...
return x;
}