# Decrypting an Affine Cipher with Modulus

I'm trying to decrypt the ciphertext vczkh which I know was encoded using an affine cipher with the equation 7x + 8(mod 26). This makes my decryption function p = (c – b) * a^-1 (mod 26) where b = 8, a = 7, c = number corresponding with cipher character starting from 0, and p is the same for plaintext. Since I can't have a fraction I calculated that 11 is congruent to 7 making my function p = (c - 8) * 11. Running this for all five letters gives me NMFWP but I know the answer is supposed to be NOVEL. I do not know what I'm doing wrong.

• "11 is congruent to 7"??? – Gerry Myerson Jan 28 '15 at 2:06
• Is it not? 7 * 11 = 77 and 77 % 26 = 1. That means congruence right? – Nick Gilbert Jan 28 '15 at 2:07
• "$a$ is congruent to $b$ modulo $c$" means $a-b$ is a multiple of $c$. Is $11-7$ a multiple of 26? – Gerry Myerson Jan 28 '15 at 2:09
• 77 divided by 26 leaves a remainder 1? – Gerry Myerson Jan 28 '15 at 2:09
• Never mind it's 15 – Nick Gilbert Jan 28 '15 at 2:16

We have:

$$y = ax + b \pmod {26} = 7x + 8 \pmod {26}$$

The inverse operation is given by:

$$x = \dfrac 1a (y - b) \pmod {26} = \dfrac{1}{7}(y - 8) \pmod {26} = 15(y-8) \pmod{26}$$

We are looking for a modular inverse (see the discussion on the Extended Euclidean algorithm) and you were slightly off on that. Try it using this online calculator. You get:

$$\dfrac{1}{7} \pmod{26} = 7^{-1} \pmod{26} = 15 \pmod {26}$$

I think you can take it from here.

• $11\times15=165=6\times26+9$. – Gerry Myerson Jan 28 '15 at 2:07
• Thanks @GerryMyerson, just transcribed it wrong - corrected! – Amzoti Jan 28 '15 at 2:09