Cryptography Reference
In-Depth Information
length 4 in this case. Then we start again with the first letter of the key, i.e., the
fifth ciphertext character is obtained by adding the fifth plaintext character n to the
first (since 5mod 4
1) character of the key, namely w . This process is continued
until all the plaintext characters are encrypted and the result is summarized in the
following table:
=
Plaintext vigenereexample
Key wordwordwordwor
Ciphertext rwxhjsihalrplzv
1.3.1 The Vigenère Cipher in Maple
We next implement inMaple the encryption and decryption functions of the Vigenère
cipher. If we want to be able to handle plaintexts in different languages, we may use
the procedure alph below to generate the corresponding alphabets. As a sample,
we include the English alphabet (also valid for other languages with Latin-based
alphabets if diacritics and ligatures are disregarded) and the Spanish alphabet, which
has the letter 'ñ' as an additional character (it also has accented vowels but they are
not regarded as separate characters, so we will disregard the accents). The procedure
takes as input the designation of the language ( en for English, es for Spanish) and
produces as output the corresponding alphabet. An obvious modification may allow
the procedure to include other languages and their alphabets if they are based on the
Latin alphabet or if their character set is a subset of the ASCII-8 code; this is left
as an exercise for the interested reader. Specifying the language is a convenient way
to select the alphabet—which will only contain lower-case letters and no punctua-
tion symbols—but the procedures for encryption and decryption that follow do not
depend on the language, only on the underlying alphabet. In contrast with this, the
cryptanalytic functions that we will give later are dependent on statistical properties
of the language itself.
> alph := proc(language)
if language = en then convert([$97 .. 122], bytes)
elif language = es then Insert(convert([$97 .. 122], bytes), 14, "ñ")
else error "Unrecognized language"
end if;
end proc:
We discuss in Chap. 3 how Maple's pseudo-random number generators can be
used to generate keys. For now we leave as an exercise to write a Maple function that
generates a pseudo-random word of specified length over a given alphabet in order
to use it as a key for the Vigenère cipher:
Exercise 1.8 Write a Maple function that uses the functions Randomize() and
Random , from the package StringTools , to pseudo-randomly generate a key for
the Vigenère cipher.
 
 
Search WWH ::




Custom Search