Vigenre cipher. The trouble with a monoalphabetic cipher is that it can be easily broken by frequency

Question:

Vigenère cipher. The trouble with a monoalphabetic cipher is that it can be easily broken by frequency analysis. The so-called Vigenère cipher overcomes this problem by encoding a letter into one of several cipher letters, depending on its position in the input document. Choose a keyword, for example TIGER. Then encode the first letter of the input text like this:

image text in transcribed

That is, the encoded alphabet is just the regular alphabet shifted to start at T, the first letter of the keyword TIGER. The second letter is encrypted according to this map:

image text in transcribed

The third, fourth, and fifth letters in the input text are encrypted using the alphabet sequences beginning with characters G, E, and R. Because the key is only five letters long, the sixth letter of the input text is encrypted in the same way as the first.
Write a program that encrypts or decrypts an input text using this cipher. Use command line argu ments as in Exercise •• P21.1 .

Data from Exercise  P21.1 Random monoalphabet cipher. The Caesar cipher, which shifts all letters by a fixed amount, is far too easy to crack. Here is a better idea. For the key, don’t use numbers but words. Suppose the keyword is FEATHER. Then first remove duplicate let ters, yielding FEATHR, and append the other letters of the alphabet in reverse order. Now encrypt the letters as follows:

image text in transcribed

Write a program that encrypts or decrypts a file using this cipher. The keyword is specified with the -k command line option. The -d command line option specifies decryption. For example,

image text in transcribed

decrypts a file using the keyword FEATHER. It is an error not to supply a keyword.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question
Question Posted: