Affine Shift Substitution Cipher.
These ciphers map the alphabet onto itself.
You can represent the alphabet using the numbers 0 - 25. A has number 0 and Z has number 25.
You can add letters together or apply formulae to them. If your operation makes the answer bigger than 25 then you must take 26 away (or find the remainder on division by 26).
Z+C=25+2=27
27=26+1=1=B
T+H=19+7=26 26+0=A
An affine cipher uses a mapping of the form: xcipher=axplain+b
a and b are constants so if we have a=1 and b=3 we get: ABCDEFGHIJKLMNOPQRSTUVWXYZ DEFGHIJKLMNOPQRSTUVWXYZABC Which is a simple shift of three.
If we have a=3 and b=0 we get: ABCDEFGHIJKLMNOPQRSTUVWXYZ ADGJMPSVYBEHKNQTWZCFILORUX A=0 3x0=0 A=A B=1 3x1=3 B=D T=19 3x19=57=26x2+5 T=F
This cipher will not work with numbers which are not co-prime with 26. Try 2 or 13 for a to see what happens.
The value of b is found from the letter used to encipher plaintext A. The value of a is then found by looking at the gap between adjacent letters after mapping into the cipher alphabet.
ABCDEFGHIJKLMNOPQRSTUVWXYZ EJOTYDINSXCHMRWBGLQVAFKPUZ A=E so b is 4 D is 5 places from E so a is 5.
The mapping is: xcipher=5xplain+4
Finding the remainder on division by 26 is an example of modular arithmetic which is used extensively in ciphers. 39=13(mod26) 75=23(mod26) or 75=-3(mod26) This is one of the reasons for using A=0 to number the letters of the alphabet. Most computer languages have commands which allow you to do modular arithmetic easily.
The Substitution Cipher Tools page contains a button for generating affine shift ciphers.
last updated 13th June 2011