Message Encryption

Short Description:

Write a program which will encrypt (and decrypt) messages.

This assignment is worth 75 points.

Goals

When you finish this homework, you should:

Formal Description

Write a program which can translate to and from a series of encodings. Your program will read from the file messages.text. This file contains a series of messages, each with encoding instructions. These messages are contained one per line. Your program should read the message, along with the encoding instructions, encode or decode the message, and print the results.

Each line in the file begins with a letter indicating the type of coding to apply. If additional parameters are required, they are given immediately after the code letter with the message following. Each message is terminated by the end of the line. There are an arbitrary number of messages in the file.

The code types supported are summarized in the table below.

Code LetterAdditional Arguments Description
R none ROT 13 (see wikipedia). Rotate each letter by 13. Care should be taken not to exceed the range of a signed character.
C int Caesar cypher ( see wikipedia) Argument will be between -25 and 25. Shift each letter (one at a time) by the given amount, but keep the result a letter. Shifting A by -1 yields a Z.
I none Use the ICAO encoding scheme given on page 236 of the book, to each alphabetic letter. In addition encode the character ' ' to the word space
i none Inverse ICAO encoding. Convert all words in the ICAO table to the corresponding letters. In addition, decode the word space to the character ' '.
A none ASCII encoding. For each character in the line, convert the character to the corresponding ASCII value. Place a space between each distinct number (not digit)
a none Inverse ASCII. Read in a series of valid integers and print the corresponding ASCII characters. Each number (not digit) will be delimited by spaces.
B 2 characters. Binary. Print the corresponding ASCII value as a 7 bit binary number. The two characters represent the encoding value for 1 and 0 respectively.
b 2 characters Binary Decode. Given a sequence of 7 character words, encoded in binary with 1 represented by the first argument and 2 represented by the second argument, print the corresponding ASCII characters.
An example input file:

R Hello World!
R Uryyb Jbeyq!
C 5 Hello World!
C -5 Mjqqt Btwqi!
I Hello World!
i HOTEL echo lima lima oscar space WHISKEY oscar romeo lima delta !
A Hello World!
a 72 101 108 108 111 32 87 111 114 108 100 33
B T F Hello World!
b T F TFFTFFF TTFFTFT TTFTTFF TTFTTFF TTFTTTT FTFFFFF TFTFTTT TTFTTTT TTTFFTF TT FTTFF TTFFTFF FTFFFFT 
X bad code letter

Will produce the following output:

Uryyb Jbeyq!
Hello World!
Mjqqt Btwqi!
Hello World!
HOTEL echo lima lima oscar space WHISKEY oscar romeo lima delta ! 
Hello World!
72 101 108 108 111 32 87 111 114 108 100 33 
Hello World!
TFFTFFF TTFFTFT TTFTTFF TTFTTFF TTFTTTT FTFFFFF TFTFTTT TTFTTTT TTTFFTF TTFTTFF TTFFTFF FTFFFFT 
Hello World!
Unknown code letter X
NOT ENCODING bad code letter

Discussion

You should make appropriate use of constants and variables.

Your identifiers should be constructed properly, with meaningful names.

You should document your code with comments.

Your output should be organized, easy to read, and make appropriate use of white space.

Your program should report an error message if the file is not available.

Your program should preserve the case of letters in the messages. For ICAO, an upper case letter is represented in all caps, for example A will encode as ALPHA, and a will encode as alpha.

For ICAO, a space should be encoded as the word space

Your program should always work. If it encounters an error, it should recover and continue.

You should report errors, such as unknown Code Letters.

All parameters will be supplied and will be in the correct format.

There will always be a space between the code letter or last parameter and the message. This space should not be part of the message.

All messages will consist of at least one character.

Start on this program early. It is not difficult, but it does require quite a bit of code.

You may not use string streams for this program.

When decoding a binary string, assume any letters that don't match the code letter given for one are zeros. (In the above example, T = 1, F = 0, the word XXXXXX1 = FFFFFFT).

Design

You should design this program, including an program design, before you implement the code. This design should be a submitted on Friday September 30, and should include: Please print this design document and hand it in at the beginning of class.

Required Files

A single source code file and a design document.

Submission

Email your final source code file to danbennett360@gmail.com.