Problem

Cryptography. The science of developing secret codes has interested many people for centur...

Cryptography. The science of developing secret codes has interested many people for centuries. Some of the simplest codes involve replacing a character, or a group of characters, with another character, or group of characters. To easily decode these messages, the decoder needs the “key” that shows the replacement characters. In recent times, computers have been used very successfully to decode many codes that initially were assumed to be unbreakable. The next set of problems considers simple codes and schemes for decoding them. Generate files to test the programs.

One step in decoding a simple code (such as the one described in Problem) without knowing the coding scheme involves counting the number of occurrences of each character. Then, knowing that the most common letter in English is ‘e,’ the letter that occurs most commonly in the coded message is replaced by ‘e.’ Similar replacements are then made based on the number of occurrences of characters in the coded message and the known occurrences of characters in the English language. This decoding often provides enough of the correct replacements that the incorrect replacements can then be determined. For this problem, write a program that reads a data file and determines the number of occurrences of each of the characters in the file. Then, print the characters and the number of times that they occurred. If a character does not occur, do not print it. (Hint: Use an array to store the occurrences of the characters, based on their ASCII codes.)

Problem

A simple code can be developed by replacing each character by another character that is a fixed number of positions away in the collating sequence. For example, if each character is replaced by the character that is two characters to the right, then the letter ‘a’ is replaced by the letter ‘c,’ the letter ‘b’ is replaced by the letter ‘d,’ and so on. Write a program that reads the text in a file, and then generates a new file that contains the coded text using this scheme. Do not change the newline characters or the EOF character.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search