# Decrypting an Affine Cipher with known characters

I am trying to cryptanalyse multiple cipher–texts that I know are encrypted by different Affine ciphers. I have already analysed the frequency that each character occurs, and compared it to a frequency table of the languages the plain-texts could be in and as a result have a pretty decent idea of what a few characters could correspond to. For example I know in one cipher-text:

X = e, S = t, V = s

Converting those into their numerical correspondences yields

23 = 4, 18 = 19, 21 = 18

I have therefore deduced that:

$4a+b=23 \pmod{26}$

$19a+b=18 \pmod{26}$

$18a+b=21 \pmod{26}$

I figure I could probably calculate the values of a and b by manually trying every iteration of a (which wouldn't be terrible since I can rule out all even values) and hoping once they all match with the same b it works for all characters, but I was just wondering if there was a faster/more reliable way of doing it Mathematically. Is there some way I can solve for $a$ and $b$ that I am unaware of?

You have 3 equations and 2 unknowns, so it is solvable, assuming a solution exists. You can plug this into any linear equation solver.

If you subtract equation 3 from equation 2, you get $a=-3$, and can solve for $b=75$. This fits equation 2 and 3, but not equation 1. So, no solution exists.

• Ah thank-you very much! So my issue is the letters I picked. Back to the frequency analysis then I guess. Perhaps I picked the wrong language? Thanks again! – Gumboots Aug 14 '14 at 5:36
• Actually, the equations are mod 26; however there still isn't any solution for the three cited. – poncho Aug 14 '14 at 12:54
• Yeah I realised that, but his answer still did enough to help me realise what was wrong. I re-analysed the character frequencies, came up with X=e, F=a and G=t and decrypted the code from that. Thanks so much for your help guys. – Gumboots Aug 15 '14 at 1:36