Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

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:



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


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

share|improve this question
Doesn't your question simply boil down to: "How to get the multiplicative inverse of an element modulo n?" –  CodesInChaos Aug 18 '12 at 22:29
You have $a$, and you have values for $x$ and $c$. Solve for $b$. This question would be more appropriate at Maths SE. –  Stephen Harris Aug 19 '12 at 0:15

1 Answer 1

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.