Affine
Description
The Affine, or linear substitution encryption, cipher provides a method of creating a monoalphabetic substitution cipher using the mathematical formula:
c = (ap + b) MOD m
where c is the cipher letter, p is the plaintext letter, a and b are cipher keys and m the number of characters in the plaintext alphabet. To use the formula the alphabet is converted to numbers where a=0, b=1, c=2 ... y=24 and z=25. A limitation of this type is that the multiplier key, a, must be co-prime to the plaintext alphabet length so using the standard A-Z alphabet of 26 letters the multiplier can't take the value of 13 or an even number.
For example using the multiplier key 7 and the additive key 4 the plaintext word 'the' is enciphered as follows:
T: c = (7*19 + 4) MOD 26 = 133 MOD 26 = 7 :H
H: c = (7*7 + 4) MOD 26 = 53 MOD 26 = 1 :B
E: c = (7*4 + 4) MOD 26 = 32 MOD 26 = 6 :G
Example
Encipher the Albert Einstein quote "The equation for ego is: One over Knowledge."
Multiplier Key: 7
Additive Key: 4
Key: c = 7p + 4 mod 26
Plaintext: The equation for ego is: One over Knowledge.
Ciphertext: HBG GMOEHIYR NYT GUY IA YRG YVGT WRYCDGZUG
Solving
All possible values are tested by brute force to find a solution. This only solves 2 x 2 affine ciphers in the range A-Z (0-25).