I know the values of $x_1, x_2, y_1, y_2$ and I would like to calculate $a$ and $b$ How do I do it because I have to program the method.
$$\begin{align*}x_1\cdot a + b = y_1 \mod 26\\ x_2\cdot a + b = y_2 \mod 26\end{align*}$$
I know the values of $x_1, x_2, y_1, y_2$ and I would like to calculate $a$ and $b$ How do I do it because I have to program the method.
$$\begin{align*}x_1\cdot a + b = y_1 \mod 26\\ x_2\cdot a + b = y_2 \mod 26\end{align*}$$
As Singhal says in his comment, to get $a,$ simply subtract the two congruences and multiply by $(x_1-x_2)^{-1}.$ (If the inverse doesn't exist, then there is no possible value of $a.$)
To get $b$ afterwards, you could either substitute the value of $a$ into one of the congruences and solve, or you could multiply the first congruence by $x_2,$ the second by $x_1,$ and subtract.
It's really like a normal system of equations, just with modular inverses instead of division.
That is done – user3341195 Feb 22 '14 at 17:07