Playfair cipher. Another way of thwarting a simple letter frequency analysis of an encrypted text is to

Question:

Playfair cipher. Another way of thwarting a simple letter frequency analysis of an encrypted text is to encrypt pairs of letters together. A simple scheme to do this is the Playfair cipher. You pick a keyword and remove duplicate letters from it. Then you fill the keyword, and the remaining letters of the alphabet, into a 5 × 5 square.

(Because there are only 25 squares, I and J are considered the same letter.) Here is such an arrangement with the keyword PLAYFAIR:

image text in transcribed

image text in transcribed

The encoding of this pair is formed by looking at the other two corners of the rectangle—in this case, FQ. If both letters happen to be in the same row or column, such as GO, simply swap the two letters. Decryp tion is done in the same way.
Write a program that encrypts or decrypts an input text using this cipher. Use command line arguments 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: