Question: Cryptogram Encoder. Cryptography is used to protect messages from unauthorized viewers. An algorithm using an encoding key scrambles the letters in a message string, making

Cryptogram Encoder. Cryptography is used to protect messages from unauthorized viewers. An algorithm using an encoding key scrambles the letters in a message string, making it unintelligible to anyone not having the key.

A simple encoding algorithm involves substituting one lower case letter for another, e.g., replace each letter in the range a to z with a different letter in this range. To insure proper decoding, each letter should be used exactly once. A 26 character string is used to define this substitution. The positions in the string correspond to the alphabet order. The character at each position of the string is the value to be substituted. Note that all other characters (upper case characters, punctuation, whitespace, etc) are unchanged. Also note that the same program can be used for both encoding and decoding a message. The only thing that changes is the conversion string.

Write a program encode.c that encodes the original text file into encrypted text.

Write a program decode.c that decodes the encrypted file into its original form.

You should allow user to choose the source and destination file names, and also to provide the name of text file that contains the encoding key string of length 26.

Details:

To encode or decode a file you should

Define a 26 character conversion string (as described above) to encode the message. Place this string in file encodekey.txt

Write a function that converts the conversion string from encodekey.txt into its complement that allows a text file to be decoded.. This function should be a part of the decode.c program.

Create an input message file cryptoin.txt containing several lines of text with upper/lower case letters, numbers, punctuation, spaces etc all intermixed. The message should be readable.

Write program encode.c that uses the string from encodekey.txt to convert the source file (e.g. cryptoin.txt) to encrypted output file (e.g. cryptoout.txt). You should do the similar with decode.c program.

Example:

convert = cdefghirslmnopqjktuvwxyzab

cryptoin.txt = Now is the time for all 99 men

cryptoout.txt = Nqy su vrg vsog hqt cnn 99 ogp

cryptoback.txt = Now is the time for all 99 men

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!