Day05 200607spring Vigenere
Day05 200607spring Vigenere
Announcements:
Assignment 1 due tomorrow in class.
Questions?
Roll Call
Today: Vigenere ciphers
Pronunciation?
Vigenere Ciphers
Idea: the key is a vector of shifts
Ex. Use a word like hidden (7 8 3 3 4 13).
Example:
The recent development of various methods of
7 8 3 3 413 7 8 3 3 413 7 8 3 3 413 7 8 3 3 413 7 8 3 3 4 13 7 8 3 3 413 7 8
015 7 20 815112122 6 8 811191718161720 1 17 8 25132416172322 2511 11017 7 5 2113
Encryption:
Repeat the vector as many times as needed to get
the same length as the plaintext
Add this repeated vector to the plaintext.
Demo
Source
0.12
0.1
Graph:
0.08
0.06
0.04
0.02
0
0 5 10 15 20 25 30
Exceptions
Consider Gadsby by Ernest Vincent
Wright, February 1939:
http://www.spinelessbooks.com/gadsby/01.html
0.1
0.08
0.06
0.04
0
0
0.14
0.12
5 10 15 20 25 30
0.06
0.1
0.04
0.02
0
0 5 10 15 20 25 30
Finding the key length
What if the frequency of letters in the plaintext
approximates A?
Then for each k, frequency of each group of letters in
position p = k (mod L) in the ciphertext approximates A.
Then loop, displacing the ciphertext by i, and counting
the number of coincidences.
Get max when displace by correct key length
So just look for the max!
shift
APHUIPLVWGIILTRSQRUBRIZNYQRXWZLBKRHFVN (0)
NAPHUIPLVWGIILTRSQRUBRIZNYQRXWZLBKRHFV (1)
VNAPHUIPLVWGIILTRSQRUBRIZNYQRXWZLBKRHF (2)
…
KRHFVNAPHUIPLVWGIILTRSQRUBRIZNYQRXWZLB (6) 5 matches
Key length: an example
Take any random pair in the ciphertext:
The letter in the top row is shifted by i (say 0)
The letter in the bottom row is shifted by j (say 2)
Demo
Another method
Method 1
Parse out the characters at positions p = 1
(mod L)
These have all been shifted the same amount
Do a frequency analysis to find shift
The most frequent letter should be e, given enough text.
Can verify to see how shift affects other letters.
Method 2
Pros?
Demo
Of my code…
Visualization
http://www.usafa.af.mil/df/dfcs/acis/applets
/Vigenere.html
Play with now and for homework
Thanks to Dr. Dino Schweitzer, USAFA,
who I met last Friday, for pointing me to
his demo!
Aren’t you glad I was at SIGCSE?
Closing Thought
What if we modified the Vigenere cipher
so that each individual letter was not
simply shifted, but the result of an affine
function?