# Cryptanalysing Affine cipher

I am trying to cryptanalyse a cipher–text encrypted by Affine cipher.

The encryption formula is: $c = f(x) = (ax+b)\bmod m$, where $a$ and $b$ are unknown constants; $x$ is a plain-text symbol, and $c$ the corresponding cipher-text symbol, both in range $[0\dots m-1]$; $m=26$ is known.

This is what I got so far:

$x=4\implies c=17$

$x=19\implies c=10$

That means that letter 4 has been encrypted into 17 (numbers are according to alphabetical order of letters in English language). Same applies to the line below. Now goes the following calculations:

$15a\equiv-7\equiv19\pmod{26}$

$a\equiv19/15\pmod{26}$

$a=3$ [because $15\cdot3=45$ and $45\equiv19\pmod{26}$]

$b=5$

I don’t get the logic which leads to obtaining $b$ value. Any help, please?

Once you know (you didn't question that) that $a = 3$, then knowing 4 goes to 17, using $f(x) = 3x + b$, we just substitute $x = 4$ to get $3 * 4 + b = 12 + b = 17 \mod 26$, where we can easily see that $b= 5$ does the job.