Homework 6, You can't break me!
Short Description:
Write a set of programs which can deal with different encryption systems.
This assignment is worth 100 points.
Goals
When you finish this homework, you should have:
- Developed your ability to use two dimensional arrays.
- Developed your ability to create code in multiple files.
Formal Description
Write programming libraries to support encryption and decryption using the cipher systems.
The code for each of these ciphers should be developed as a stand-alone library which can be included in any program. Inclusion of one cipher should not require inclusion of any of the others.
For the Vigenere cipher, you are REQUIRED to create and use a Vigenere square or Vigenere table.
You should produce five programs: Caesar, VIC, Playfair, Vignere, CodeBench. Each of these programs should be interactive and user friendly.
- Caesar: The user is asked for an offset and a text, the encrypted (or decrypted) text is printed. Non-alphabetic characters are printed as is.
Example:
Caesar Cypher Program:
Enter the shift amount: -3
Enter the text: Qeb Nrfzh Yoltk Clu Grjmp Lsbo Qeb Ixwv Ald
The encrypted text is: The Quick Brown Fox Jumps Over The Lazy Dog
- VIC: The user is asked for an encryption key, if they are encrypting or decrypting the message, and the message. Non-alphabetic characters are printed as is.
Example:
Vigenere Cipher Program:
Enter the encryption key: LEMON
Are you encrypting (e) or decrypting (d) the message? : d
Enter the text: Lxfopv ef rnhr
The decrypted text is: Attack at dawn
- Playfair: The user is asked for an encryption key and the message and if they are encrypting or decrypting. Non-alphabetic characters are printed as is.
Example:
Playfair Cipher Program:
Enter the encryption key: Playfair example
Are you encrypting (e) or decrypting (d) the message? : d
Enter the Phrase: Bmod zbx dnab ek udm uiexm ouvif
The decrypted text is: Hide the gold in the tree stump.
- Vic: The user is asked for an encryption key, the message and if they are encrypting or decrypting. Non-alphabetic characters are printed as is.
Example:
VIC Cipher Program:
Enter the encryption key: ET AON RIS
Are you encrypting (e) or decrypting (d) the message? : e
Enter the Phrase: Attack at dawn.
The encrypted text is: 31132127 31 223655.
- CodeBench: This program is a combination of the first four. The user should be presented with a menu, which includes a choice for the above listed ciphers and a quit option. After the user selects a cipher method, the dialog should be similar to that above. The program should allow the user to encrypt/decrypt many messages with many different ciphers.
You should also create library of utility functions, which are common to two or more ciphers. This library might contain, for example, the following functions:
- void MakeUppercase(string text); : translate all of the letters in the text to upper case.
- string UniqueLetters(string text); : return a list of all of the unique letters in a given string.
- int PositionInAlphabet(char letter); : return the position of a letter in the alphabet (a=0, b=1 ...)
- char LetterFromPosition(int position); : return the letter at a given position (opposite of PositionInAlphabet).
There will probably be other such functions. You should not have the same function implemented in two files for this project. If two encryption systems require a function, place it in this library.
Discussion
- Whenever possible, eliminate repeated code by building subroutines. If you find you are repeating code, pull it out and put it into a subroutine.
- You should probably write some experimental code, and then revise your design.
- You should create a sub-directory and perform all work for this project within this directory.
- If you need help, you should ask.
- Please do not put this work off until the weekend before it is due.
- If you require help with the Makefile, or creating the tar file, please ask for assistance.
Required Files
A tar file containing only source code and a Makefile.
A tar file is a file which compresses many files and folders into a single file. TAR stands for Tape ARchive, and is a utility which has existed for most of the history of UNIX. It maintains dates, permissions and ownership of the file. It is a POSIX standard.
To create a tar file:
These instructions assume all of your work is in a folder called program5. Following these instructions you will produce a file called submission.tgz.
- Remove all object files and executable files from the folder.
- In the folder containing program5 (not in the program5 folder, but its parent) issue the command
tar cvzf submission.tgz program5
- This will create a file called submission.tgz
- You may call it anything you wish. This example the name was submission but any name will do. The convention is to call the tar file for the directory program5
- The extension .tgz stands for compressed tar file, and should be used.
- You should submit this file.
- If you wish, you may look at the contents of this file with the command
tar tzf submission.tgz
tar xvzf submission.tgz
You should probably do this in another directory. This will create a new folder called program5 and extract all of the files in the tar file into it.
Submission
Email the tar file of your source code to danbennett360@gmail.com by class time of the due date.