Random monoalphabet cipher Solution

Exercise P9.2. Random monoalphabet cipher. The Caesar cipher, which shifts all let-
ters by a fixed amount, is far too easy to crack. Here is a better idea. As the key,
don’t use numbers but words. Suppose the key word is FEATHER. Then first remove
duplicate letters, yielding FEATHR, and append the other letters of the alphabet in
reverse order:
F E A T H R Z Y X W V U S Q P O N M L K J I G D C B
Now encrypt the letters as follows:
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
F E A T H R Z Y X W V U S Q P O N M L K J I G D C B
Write a program that encrypts or decrypts a file using this cipher. For example, crypt -d -kFEATHER encrypt.txt output.txt
decrypts a file using the keyword FEATHER. It is an error not to supply a keyword.

PLEASE DON’T DO THIS ONE; GO TO THE NEXT QQUESTION : Exercise P9.6. Junk mail. Write a program that reads in two files: a template and a
database. The template file contains text and tags. The tags have the form |1| |2|
|3|… and need to be replaced with the first, second, third, … field in the current
database record.
A typical database looks like this:
Mr.|Harry|Hacker|1105 Torre Ave.|Cupertino|CA|95014
Dr.|John|Lee|702 Ninth Street Apt. 4|San Jose|CA|95109
Miss|Evelyn|Garcia|1101 S. University Place|Ann Arbor|MI|48105
And here is a typical form letter:
To:
|1| |2| |3|
|4|
|5|, |6| |7|

Dear |1| |3|:

You and the |3| family may be the lucky winners of $10,000,000 in the C++
compiler clearinghouse sweepstakes! ...

Exercise P9.7. The program in Section 9.6 only locates one record and updates the salary. Write a program that raises or lowers the salaries of all employees by a given percentage.



Powered by