# Decrypting an Affine Cipher $e(m)=am+b\pmod{27}$ knowing $e(8)\equiv 14$ and $e(26)\equiv 5$

I began by setting up a system of linear equations: $$14\equiv 8a+b \pmod{27}$$ $$5\equiv 26a+b\pmod{27}$$ and then subtracted them to get: $$9\equiv 9a \pmod{27}$$. I know $$9$$ doesn't have a multiplicative inverse modulo $$27$$ but $$a=1$$ would solve this. I'm afraid I must be making some mistake somewhere, however, as solving this all the way through gives me $$b=6$$ and then translating the message doesn't quite make sense.

• You missed several solutions. – Randall Feb 24 at 20:08

$$9a\equiv 9 \mod{27}$$ $$a \equiv1 \mod3$$ $$\therefore a=1+3k$$ $$b\equiv14-8a \mod{27}$$ $$b=14-8(1+3k)+27m$$ $$\therefore b=6-24k+27m$$ Where $$k,m\in\mathbb{Z}$$.

• So $(a,b)\in \{(1,6),(4,9),(7,12),(10,15),(13,18),(16,21),(19,24),(22,0),(25,3)\}$. Only the ones with invertible $a$, namely $a=1,7,19,25$ warrant further investigation. The others would be uninvertible. – Henno Brandsma Feb 24 at 23:07
• They are all invertible mod 27 since its only prime divisor is 3 right? – joseph Feb 25 at 1:33
• @josephF yes, sorry, I switched to modulo $26$ in my head again (which is also done sometimes in some texts). – Henno Brandsma Feb 25 at 21:58

$$9\equiv 9a \ \pmod{27} \Rightarrow 9(1-a)\equiv 0\ \pmod{27} \Rightarrow 1-a\equiv 0 \pmod{3} \Rightarrow a=1+3k,\ k\in\mathbb{Z}$$

• okay so $a=1,4,7,10,13,16,19,22$ or $25$? – joseph Feb 24 at 20:17
• No, I never said that. I was talking about the answer, not your comment. Whether anyone writes $=$ or $\equiv$ hardly matters as long as the context is clear. – Randall Feb 24 at 20:20
• @Randall You're right! My mistake, I'll try to fix it – giannispapav Feb 24 at 20:29
• Yes, that's correct now. I removed my downvote. – Randall Feb 24 at 20:35
• Use \pmod{27} for $\pmod{27}$ ("parenthesized mod" I suppose) for nicer results. – Henno Brandsma Feb 24 at 22:33