copyright Steve J. Hodges

CS19 Spring 2018

Assignment 6 (Solitaire Encryption)

Project Directory


Resulting Executable


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 Run

$ ./p6 e deck.txt
Enter message to be encrypted (non-letters ignored)
This is a test.
Plaintext message is: THISISATESTXXXX
The encrypted message is: IBSRPGWASOPKXKU

Sample Run

$ ./p6 d deck.txt
Enter message to be decrypted:
The decrypted message is: THISISATESTXXXX

The starting deck is the key to decoding the message. Even a slight change to the key will result in different encryptions and decryptions! In this example, I made a different key by only swapping the nine and the ten at the start of the sample deck.

Sample Run

$ ./p6 d anotherDeck.txt
Enter message to be decrypted:
The decrypted message is: EHJSSFVMCOPPBUI

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.)