Cryptography Reference
In-Depth Information
> VigenereKeyFind(c);
"juliuscaesar"
Now we can go a step further, and give a Maple function which will cryptanalyze
a ciphertext and output the corresponding plaintext:
> VigenereCryptanalysis := proc(ciphertext,
max:=floor(StringTools:-Length(ciphertext)/15),{language:=en})
Vigenere(VigenereKeyFind(ciphertext, max, ':-language'=language), ciphertext, dec,
':-language'=language)
end proc:
The result of applying this function to the sample ciphertext above is the following:
> pt := VigenereCryptanalysis(c);
"friendsromanscountrymenlendmeyourearsicometoburycaesarnottopraisehimtheevilthatmen\
dolivesafterthemthegoodisoftinterredwiththeirbonessoletitbewithcaesarthenoblebrutus\
hathtoldyoucaesarwasambitiousifitweresoitwasagrievousfaultandgrievouslyhathcaesaran\
sweredit"
Let us experiment a bit to see if the length of the ciphertext given above
may be enough to cryptanalyze the Vigenère cipher even if a longer key is used.
We may encrypt again the plaintext above, using a longer key, and still be able
to cryptanalyze the resulting ciphertext. For example, let us encrypt it with key
"willshakespeare" , without showing the ciphertext on screen, and let us try
to recover the key used from the ciphertext:
> c2 := Vigenere("willshakespeare", pt, enc):
VigenereKeyFind(%);
"willshakespeare"
In this case, a ratio between ciphertext length and key length below 20 is enough
for the successful recovery of the key. This is often the case but in some cases it may
not be enough. For example, if the key is a word with many repetitions, then it may
be more difficult to find. Let us now see what happens if we use a still longer key
with the above plaintext:
> Vigenere("williamshakespeare", pt, enc):
VigenereKeyFind(%);
"zilypeqrd"
In this case, the result is not even remotely accurate but this is due to the
fact that the key used is longer than the maximum length examined by the pro-
cedure keyword (there are fewer than 15 ciphertext characters for each key
character). We can avoid this difficulty by specifying a longer maximum length,
for example, 20:
> Vigenere("williamshakespeare", pt, enc):
VigenereKeyFind(%, 20);
"williamshakkspuare"
Now the result obtained is still incorrect but is much closer to the correct one
and, by using this key, one could easily recover the plaintext as only a few scattered
characters (just two out of every 18) would be incorrect and the redundancy of the
language would easily compensate for it.
Search WWH ::




Custom Search