Cracking the Vigenere Cipher knowing the keyword length.
by fortenforge, Sep 7, 2009, 10:09 PM
VNZZNXVRBEGBJAZIETKPKFFXJSBFNMYEKVILKHXJAMZSYRCMZOGFFPRTVYIG
XAYZGFVNMFFMYEBDAZZNTKIHEEFVRZVTAIONXHMYETZDHWSVZEGTEMFAICAG
FNIRPXITAVNBKMHMELKOKVAEZSTKIHEIGJTHEEHIMXKAEFRXEEKXYMYEGZTU
IIGXSAFMXJTHDEGFRPFMXETAVNBKEEVVTKELKHXJTTEDTIDHWLBMIGXAGUAW
USMFTAVCHDFHITLFFEZFXKHBJILKHXVNZZNXVRLYIZYPKZVBCEZVHXIBXITA
FOOVR
Here is our ciphertext, we know that it was encrypted using a vigenere cipher of length 3.
We split the text into 3 parts, if we call the first letter
, the second letter
, the third letter
, and so on, the
th group has all letters
, the first group has all letters
, and the second group has all letters
.
VZVEJIKFJFYVKJZRZFRYXZVFYDZKEVVIXYZWZTFCFRIVKMKVZKEJEIKFEXYZ
IXFJDFFEVKVKKJEIWMXUUFVDIFZKJKVZVYYZCVIIFV
NNRGAEPFSNEIHASCOFTIAGNFEANIERTOHEDSEEAANPTNMEOASIITEMAREYET
ISMTERMTNEVEHTDDLIAASTCFTFFHIHNNRIPVEHBTOR
ZXBBZTKXBMKLXMYMGPVGYFMMBZTHFZANMTHVGMIGIXABHLKETHGHHXEXKMGU
GAXHGPXABETLXTTHBGGWMAHHLEXBLXZXLZKBZXXAO
Let us start with group 1.
VZVEJIKFJFYVKJZRZFRYXZVFYDZKEVVIXYZWZTFCFRIVKMKVZKEJEIKFEXYZ
IXFJDFFEVKVKKJEIWMXUUFVDIFZKJKVZVYYZCVIIFV
We know that all the letters in this group have been encrypted in a caesar cipher of a certain key, to find the key we can sort through all 26 keys and decide which one matches the frequency analysis of normal english text.
A B C D E _F _G H I J K _L M N O P Q R S T U V _W X Y Z
0 0 2 3 7 _13 0 0 9 7 12 0 2 0 0 0 0 3 0 1 2 15 2 5 7 12
8 2 3 4 13 2 _2 6 7 0 1 _4 2 7 8 2 0 6 6 9 3 1 _2 0 2 0
The first row is the percentages of frequency in the ciphertext and the second row is normal english. We see a row of 4 0's in the cipher text row, that probably corresponds to WXYZ in the english row. We have to shift the first 0 backwards 17 spaces to correspond to the W. But are we convinced that the key is 17? Well, when we shift the 15 in the first row back 17 spaces it corresponds to E, because E is the most commonly occurring letter in the English language and because 15 is the highest number in the first row, we can be pretty confident that 17 is the key. If A = 0 , B = 1 and so on 17 = R. R is the first letter of the keyword for the vigenere cipher. When decrypted in a caesar cipher of key R, our text becomes
EIENSRTOSOHETSIAIOAHGIEOHMITNEERGHIFICOLOARETVTEITNSNRTONGHI
RGOSMOONETETTSNRFVGDDOEMROITSTEIEHHILERROE.
When inserted back in our ciphertext in the correct place our ciphertext becomes
E**I**E**N**S**R**T**O**S**O**H**E**T**S**I**A**I**O**A**H**
G**I**E**O**H**M**I**T**N**E**E**R**G**H**I**F**I**C**O**L**
O**A**R**E**T**V**T**E**I**T**N**S**N**R**T**O**N**G**H**I**
R**G**O**S**M**O**O**N**E**T**E**T**T**S**N**R**F**V**G**D**
D**O**E**M**R**O**I**T**S**T**E**I**E**H**H**I**L**E**R**R**
O**E*
* represents an unknown letter.
If we examine the 2nd group
NNRGAEPFSNEIHASCOFTIAGNFEANIERTOHEDSEEAANPTNMEOASIITEMAREYET
ISMTERMTNEVEHTDDLIAASTCFTFFHIHNNRIPVEHBTOR
you will find that it's frequency analysis is already very close to the English language. This tells us that it was encrypted with a caesar cipher of shift 0. The corresponding letter is A. (If you don't believe me, use the same method that we did on the 1st group).
Now we can plug these letters strait back into our ciphertext we get:
EN*IN*ER*NG*SA*RE*TP*OF*SS*ON*HE*EI*TH*SA*IS*AC*IO*OF*AT*HI*
GA*IG*EN*OF*HE*MA*IN*TI*NE*ER*ET*RO*GH*HE*ID*FS*IE*CE*OA*LA*
ON*AP*RT*EN*TM*VE*TO*EA*IS*TI*NI*ST*NE*RM*TA*OR*NE*GY*HE*IT*
RI*GS*OM*ST*ME*OR*OM*NT*EN*TE*EV*TE*TH*ST*ND*RD*FL*VI*GA*DA*
DS*OT*EC*MF*RT*OF*IF*TH*SI*TH*EN*IN*ER*HI*HP*IV*LE*EH*RB*RT*
OO*ER
Now at this point we have several options. We could use the same method on group 3 to find the plaintext as we did on groups 1 and 2. We know 2/3 of the plaintext so we can guess with fairly good accuracy the rest of the plaintext. We also know what 2/3 of the letters in the keyword are. RA* is the current keyword. Because the keyword is usually an actual word, we can guess at the key letter for the last group. Possible endings are N for 'RAN', T for 'RAT', B for 'RAB' (the person sending the message might be a Harry Potter fan) or G for 'RAG'. We could then try each of these letters until we find the correct answer.
Using any of the methods you would probably find that the last key letter was 'T', and that the decrypted text was,
GEIIGAREITRSETFTNWCNFMTTIGAOMGHUTAOCNTPNPEHIOSRLAONOOELERTNB
NHEONWEHILASEAAOINNDTHOOSLEISEGESGRIGEEHV
Plugging this back into our partially decrypted message and formatting it a bit we get:
Engineering is a great profession. There is the satisfaction of watching a figment of the imagination emerge through the aid of science to a plan on paper. Then it moves to realisation in stone or metal or energy. Then it brings homes to men or women. Then it elevates the standard of living and adds to the comforts of life. This is the engineer's high privilege.
--Herbert Hoover
XAYZGFVNMFFMYEBDAZZNTKIHEEFVRZVTAIONXHMYETZDHWSVZEGTEMFAICAG
FNIRPXITAVNBKMHMELKOKVAEZSTKIHEIGJTHEEHIMXKAEFRXEEKXYMYEGZTU
IIGXSAFMXJTHDEGFRPFMXETAVNBKEEVVTKELKHXJTTEDTIDHWLBMIGXAGUAW
USMFTAVCHDFHITLFFEZFXKHBJILKHXVNZZNXVRLYIZYPKZVBCEZVHXIBXITA
FOOVR
Here is our ciphertext, we know that it was encrypted using a vigenere cipher of length 3.
We split the text into 3 parts, if we call the first letter







VZVEJIKFJFYVKJZRZFRYXZVFYDZKEVVIXYZWZTFCFRIVKMKVZKEJEIKFEXYZ
IXFJDFFEVKVKKJEIWMXUUFVDIFZKJKVZVYYZCVIIFV
NNRGAEPFSNEIHASCOFTIAGNFEANIERTOHEDSEEAANPTNMEOASIITEMAREYET
ISMTERMTNEVEHTDDLIAASTCFTFFHIHNNRIPVEHBTOR
ZXBBZTKXBMKLXMYMGPVGYFMMBZTHFZANMTHVGMIGIXABHLKETHGHHXEXKMGU
GAXHGPXABETLXTTHBGGWMAHHLEXBLXZXLZKBZXXAO
Let us start with group 1.
VZVEJIKFJFYVKJZRZFRYXZVFYDZKEVVIXYZWZTFCFRIVKMKVZKEJEIKFEXYZ
IXFJDFFEVKVKKJEIWMXUUFVDIFZKJKVZVYYZCVIIFV
We know that all the letters in this group have been encrypted in a caesar cipher of a certain key, to find the key we can sort through all 26 keys and decide which one matches the frequency analysis of normal english text.
A B C D E _F _G H I J K _L M N O P Q R S T U V _W X Y Z
0 0 2 3 7 _13 0 0 9 7 12 0 2 0 0 0 0 3 0 1 2 15 2 5 7 12
8 2 3 4 13 2 _2 6 7 0 1 _4 2 7 8 2 0 6 6 9 3 1 _2 0 2 0
The first row is the percentages of frequency in the ciphertext and the second row is normal english. We see a row of 4 0's in the cipher text row, that probably corresponds to WXYZ in the english row. We have to shift the first 0 backwards 17 spaces to correspond to the W. But are we convinced that the key is 17? Well, when we shift the 15 in the first row back 17 spaces it corresponds to E, because E is the most commonly occurring letter in the English language and because 15 is the highest number in the first row, we can be pretty confident that 17 is the key. If A = 0 , B = 1 and so on 17 = R. R is the first letter of the keyword for the vigenere cipher. When decrypted in a caesar cipher of key R, our text becomes
EIENSRTOSOHETSIAIOAHGIEOHMITNEERGHIFICOLOARETVTEITNSNRTONGHI
RGOSMOONETETTSNRFVGDDOEMROITSTEIEHHILERROE.
When inserted back in our ciphertext in the correct place our ciphertext becomes
E**I**E**N**S**R**T**O**S**O**H**E**T**S**I**A**I**O**A**H**
G**I**E**O**H**M**I**T**N**E**E**R**G**H**I**F**I**C**O**L**
O**A**R**E**T**V**T**E**I**T**N**S**N**R**T**O**N**G**H**I**
R**G**O**S**M**O**O**N**E**T**E**T**T**S**N**R**F**V**G**D**
D**O**E**M**R**O**I**T**S**T**E**I**E**H**H**I**L**E**R**R**
O**E*
* represents an unknown letter.
If we examine the 2nd group
NNRGAEPFSNEIHASCOFTIAGNFEANIERTOHEDSEEAANPTNMEOASIITEMAREYET
ISMTERMTNEVEHTDDLIAASTCFTFFHIHNNRIPVEHBTOR
you will find that it's frequency analysis is already very close to the English language. This tells us that it was encrypted with a caesar cipher of shift 0. The corresponding letter is A. (If you don't believe me, use the same method that we did on the 1st group).
Now we can plug these letters strait back into our ciphertext we get:
EN*IN*ER*NG*SA*RE*TP*OF*SS*ON*HE*EI*TH*SA*IS*AC*IO*OF*AT*HI*
GA*IG*EN*OF*HE*MA*IN*TI*NE*ER*ET*RO*GH*HE*ID*FS*IE*CE*OA*LA*
ON*AP*RT*EN*TM*VE*TO*EA*IS*TI*NI*ST*NE*RM*TA*OR*NE*GY*HE*IT*
RI*GS*OM*ST*ME*OR*OM*NT*EN*TE*EV*TE*TH*ST*ND*RD*FL*VI*GA*DA*
DS*OT*EC*MF*RT*OF*IF*TH*SI*TH*EN*IN*ER*HI*HP*IV*LE*EH*RB*RT*
OO*ER
Now at this point we have several options. We could use the same method on group 3 to find the plaintext as we did on groups 1 and 2. We know 2/3 of the plaintext so we can guess with fairly good accuracy the rest of the plaintext. We also know what 2/3 of the letters in the keyword are. RA* is the current keyword. Because the keyword is usually an actual word, we can guess at the key letter for the last group. Possible endings are N for 'RAN', T for 'RAT', B for 'RAB' (the person sending the message might be a Harry Potter fan) or G for 'RAG'. We could then try each of these letters until we find the correct answer.
Using any of the methods you would probably find that the last key letter was 'T', and that the decrypted text was,
GEIIGAREITRSETFTNWCNFMTTIGAOMGHUTAOCNTPNPEHIOSRLAONOOELERTNB
NHEONWEHILASEAAOINNDTHOOSLEISEGESGRIGEEHV
Plugging this back into our partially decrypted message and formatting it a bit we get:
Engineering is a great profession. There is the satisfaction of watching a figment of the imagination emerge through the aid of science to a plan on paper. Then it moves to realisation in stone or metal or energy. Then it brings homes to men or women. Then it elevates the standard of living and adds to the comforts of life. This is the engineer's high privilege.
--Herbert Hoover