For an affine cipher, we know that the encryption function is of the form:
e(x) = ax + b (mod 26)
From the given plaintext and corresponding ciphertext, we can see that:
14 = e(8) = 8a + b (mod 26)
15 = e(1) = a + b (mod 26)
(note: 'h' = 8, 'a' = 1, 'N' = 14, 'O' = 15)
So now we just need to solve for a and b. I'll start by subtracting the second equation from the first equation to get:
-1 = 7a (mod 26)
25 = 7a (mod 26)
To get a by itself, we need to determine the multiplicative inverse of 7 mod 26. After some trial and error, we find the the number we are looking for is 15:
7 * 15 = 105 = 1 (mod 26)
So we get:
25 = 7a (mod 26)
25 * 15 = a (mod 26)
a = 375 = 11 (mod 26)
Now plug this value for a back into the second equation:
15 = 11 + b (mod 26)
b = 4 (mod 26)
Thus, the encryption function becomes:
e(x) = 11x + 4 (mod 26)