copyright Steve J. Hodges   http://steveh.net/cs19/cs19-hw06.html

CS19 Spring 2016

Assignment 6 (Solitaire Encryption)

Project Directory

19-6

Resulting Executable

p6

Description of the program

In this assignment you will code a simplified version of Bruce Schneier's Solitaire Encryption Algorithm. Your program will be able to encrypt or decrypt messages.

Here's a description of the algorithm that you will implement (from Stanford University Nifty Assignments archive of SIGCSE meetings):

You may use either your own doubly linked list implementation or an STL sequence container (your preference) to hold the deck of cards. Please design or select your functions carefully to minimize slow operations. Whichever type of container you choose, consider the option of temporary, local, containers to help with the "shuffling" of values.

Your program should be used as described below.

./p6 e deck.txt
./p6 d deck.txt

Sample deck data file (containing the two digit, space separated integer values 01-28 on one line.)

Sample Runs

$ ./p6 e deck.txt
Solitaire Encryption - sample solution
Enter a message to encode:
This is a test.
Plaintext message is:
THISISATESTXXXX
The encrypted message is:
IBSRPGWASOPKXKU

$ ./p6 d
Solitaire Encryption - sample solution
Deck file? deck.txt
Enter a message to decode:
IBSRPGWASOPKXKU
The decrypted message is:
THISISATESTXXXX

If the user omits the name of the deck file on the command line, prompt the user for the file name before prompting for the text to encrypt or decrypt. If the user omits the "e" or "d" command line parameter, the program should quit after printing a usage message. After you have printed out the results, your program should quit (i.e. do not encode or decode multiple strings in one program invocation.)

A sample message encrypted with the provided deck file: TGKHSAAFCQNAAZBNQPXMZBVHLLYRDAQSEJEEXAUDIQLIGFHPNMLSVOBTSSCY