##Caesar's Cipher## Caesar's cipher is to move a letter 3 places forward in the alphabet.
#Caesar's cipher is most effective against people who are illiterate
A generalization of Caesar's cipher is to shift not by 3, but by some amount .
This makes it a cipher with a key
#Caesar's cipher is just the shift cipher with =3
#Shifting backwards by 3 undoes Caesar's cipher!
#Shifting backwards by undoes a shift forward by !
The shift cipher is not a good cipher!
But why, exactly?
Because the key space is very small.
We can check 26 possibilities in a millisecond.
Note that the first 5 characters of the message more or less tells us if the key is correct or not.
#Exercise: Decrypt KTBG BG LITBG YTEEL BG MAX IETBG
#The above is a ciphertext only attack because the plaintext is not known.
It is brute force because it just tries every key.
Sometimes we know the plaintext and the ciphertext and just want to find the key.
This is a known plaintext attack. Example:
Thus the shift is , or equivalently .
Note that while the time necessary for a ciphertext only attack was (in this case) proportional to the keyspace size, the time necessary for a known plaintext attack is constant.
This makes sense: Having more information about the cipher helps you break it.
###Note that the algebraic form of the shift cipher is
This assumes that the alphabet is {0,1,...,25} rather than {A,B,C,...,Z}.
But this is just a superficial difference.
###The Affine Cipher is slightly more complex
Now the key is a pair of numbers in {0..25} and the keyspace has size seems to be
Actually we will see below that some are unsuitable and there are only
pairs (a,b) that give an invertible .
It is important that be an invertible function, because we eventually want to decrypt things!
How do we invert the affine cipher?
Does it even have an inverse?
##Note that is not one-to-one! Therefore it has no inverse.
The problem is basically that there is no element in {0..25} for which
Note that if there were such a then we could invert by applying .
Meaning, that:
####The 12 numbers in {0..26} which are relatively prime to 26 do have inverses.
####These invertables (mod 26) are the only suitable choices for in .
If we denote the multiplicative inverse of mod 26 by then
for we decrypt by
Proof:
##The affine cipher is a terrible cipher
But it illustrates some important things.
For one thing, the keyspace is still too tiny.
For another thing, it does not disguise the statistics of the language enough.
We will crack it in a lab, or as an assignment (maybe).
#Cryptograms: Substitutions
##A cryptogram is a permutation of the alphabet.
###The key is the permutation used to mix up the alphabet.
##The decrypt is the reverse permutation
##Now the keyspace is huge ###There are ways to permute objects.
####But still, a simple substitution is easily cracked with statistics
###Note that we didn't know the plaintext, only its statistical profile ####And we didn't just mechanically search the (enormous) keyspace. #####This is an example of a non-brute-force attack.