Project #2: Breaking the Code

Submit: Turn in your codebreaker.c source file using the turnin command on morbius.mscsnet.mu.edu or one of the other Systems Lab machines.

Work is to be completed individually. Be certain to include your name in the file. You may submit multiple times, but only the last turnin will be kept. The automatic submission system will not accept work after the deadline. (See turnin instructional video HERE. Note that the video is for a different course number, and that Morbius's domain name has changed since the video was made: morbius.mscs.mu.edu -> morbius.mscsnet.mu.edu)

Include a comment block at the very top of each file that contains the following:

/**
 * COSC 3250 - Project #
 * Explain briefly the functionality of the program.
 * @author [your name]
 * Instructor [your instructor]
 * TA-BOT:MAILTO [your email address]
 */

Ring of Xinu

Unbeknownst to Lord Xinu (Dark Lord of the Mips), his super-secret, Wormhole X-Treme! cereal box decoder is actually a pretty lousy secret message channel. (Lord Xinu's specialty is embedded operating systems, not cryptography.)

Thwart Lord Xinu's insidious scheme to commandeer the world's home networking appliances by building a program that will crack his decoder ring's code.

Simple Cryptanalysis

The downfall of Lord Xinu's decoder ring scheme is that there are effectively only 27 possible key values. You can use any number as the key, but after the first modulus is taken, you're back to 27 real possibilities.

Code breakers often begin attacking such a weak cipher by trying all of the possibilities, hoping one of the results will obviously be the original message.

How will our program recognize when we've found the right key? Many algorithms exist, but one common technique is to examine the frequency of letters in the deciphered text. Written English has a known profile of letter frequencies. Let us assume that the correct key will result in the deciphered text that results in the most occurrences of the letter 'E'. This is a very close pass, but actually gives us the wrong key for most test inputs -- it gives us the incorrect key value that happens to decipher space characters from the original in the letter 'E'. Instead, we want the key that gives us the next largest number of E's in the deciphered text.

Construct a program that takes ciphertext output from the encoder-ring program, tries decoding it with all 27 possible keys, and outputs the key value that resulted in the second largest number of E's, followed by the deciphered text.

We have provided an example program for your reference, executable on Morbius as ~brylow/os/Projects/codebreaker.

Notes


[back]

[Revised 2022 Feb 02 12:52 DWB]