User Tools

Site Tools


Sidebar

projects

cci0 (due 20170826)
wcp1 (due 20170826)
dtr0 (due 20170830)
wcp2 (due 20170902)
sof0 (due 20170906)
wcp3 (due 20170909)
dow0 (due 20170913)
wcp4 (due 20170916)
mbe0 (due 20170920)
wcp5 (due 20170923)
cbf0 (due 20170927)
wcp6 (due 20170930)
cos0 (due 20171004)
wcp7 (due 20171007)
pnc0 [metrics] (due 20171018)
mbe1 (BONUS – due 20171018)
wcp8 (due 20171021)
pnc1 [metrics] (due 20171025)
wcp9 (due 20171028)
gfo0 (due 20171101)
wcpA (due 20171104)
gfo1 (due 20171108)
wcpB (due 20171111)
gfo2 (due 20171115)
wcpC (due 20171118)
haas:spring2018:cprog:projects:secretagent

Project: SECRET AGENT

A project for COURSENAME by YOUR NAME during the SEMESTER YEAR.

This project was begun on DATE and is anticipated to take TIME UNIT to complete. Project was completed on MONTH DAY, YEAR.

Objectives

State the purpose of this project. What is the point of this project? What do we hope to accomplish by undertaking it?

Prerequisites

In order to successfully accomplish/perform this project, the listed resources/experiences need to be consulted/achieved:

  • successful completion of project #0 and solid understanding of pertinent topics
  • familiarity with memory allocation via malloc(3)
  • familiarity with looking up C function parameters/information in the manual
  • familiarity with if statements, especially in use for error detection
  • familiarity with pointers and pointer arithmetic
  • familiarity with loops
  • file I/O

Background

State the idea or purpose of the project. What are you attempting to pursue?

Providing any links to original source material, such as from a project page, is a good idea.

You'll want to give a general overview of what is going to be accomplished (for example, if your project is about installing a web server, do a little write-up on web servers. What is it, why do we need one, how does it work, etc.)

Scope

This project will test your familiarity with more involved algorithms, storage, and control structures.

Encoding is the process of converting a message into a coded form.

Decoding is the reverse- retrieving that original message from an encoded form.

In this project you will write a 2 programs: one that will take a plain text message and convert it into a coded form (largely indecipherable to the regular english expecting eye) using a given cipher key, and another that will reverse the process (or decipher), when given the appropriate key.

The key is a numeric used to rotate the alphabet a set amount. Where A would normally equal 1, and Z 26, using a cipher key of 1 to shift 1 position to the right; A would now equal 2 (or B), B is now 3 (or C), and Z would be 1 (A).

Your encoding program can operate as follows:

  • obtains its cipher key from a text file called “key.txt”
  • or, if you prefer, use command-line arguments to provide the key
  • obtains the input message from a file called “plain.txt”
  • if “plain.txt” is blank, or does not exist, the program should prompt the user to enter the message via STDIN
  • outputs the ciphertext message to STDOUT AND saves it to a file called “cipher.txt”
  • implement error checking to avoid segfaults

The decoding operation is essentially the reverse (shifting to the left). I'd suspect you could reuse much of the same logic.

Your decoding program:

  • obtains its cipher key from a text file called “key.txt”
  • or, if you prefer, use command-line arguments to provide the key
  • obtains the input cipher from a file called “cipher.txt”
  • if “cipher.txt” is blank, or does not exist, the program should prompt the user to enter the message via STDIN
  • outputs the plaintext message to STDOUT AND saves it to a file called “plain.txt”
  • implement error checking to avoid segfaults

If you want, you may implement both functionalities into one program so long as you provide a mechanism for the user to access both operations (but note this is not required for successful completion of this project).

Code

The encipher code:

/*
 * encipher.c - program that encodes a message according to a key
 *
 *
 * Compile with: gcc -o encipher encipher.c
 *
 * Place key value in: key.txt
 * Place message to encipher in: plain.txt
 * Enciphered message placed in: cipher.txt
 *
 * Execute with: ./encipher    or    ./encipher KEYVAL
 *
 */
 
#include <stdio.h>
 
int main(int argc, char **argv)
{
    printf("Hello, World!\n");
 
    if(argc == 2)
    {
        printf("%s was called with the following argument: %d\n", argv[0], atoi(argv[1]));
    }
    else
    {
        printf("No argument was provided. Get value from file.\n");
    }
    return(0);
}

Don't forget your deciphering code as well.

Execution

An example run of the enciphering process:

lab46:~/src/cprog/project1$ ./encipher 7
Cipher key provided on command line: 7

Message is: Traveling the world is the best way to study geography.
 Cipher is: Ayhclspun aol dvysk pz aol ilza dhf av zabkf nlvnyhwof.

lab46:~/src/cprog/project1$ cat cipher.txt
Ayhclspun aol dvysk pz aol ilza dhf av zabkf nlvnyhwof.
lab46:~/src/cprog/project1$ 

Now, we switch gears and decipher a different (previously enciphered) message:

lab46:~/src/cprog/project1$ echo "12" > key.txt
lab46:~/src/cprog/project1$ echo "Ftq yagzfmuz mfq ftq pas, MZP TAI!" > cipher.txt
lab46:~/src/cprog/project1$ ./decipher
Cipher key found in key.txt: 12

 Cipher is: Ftq yagzfmuz mfq ftq pas, MZP TAI!
Message is: The mountain ate the dog, AND HOW!

lab46:~/src/cprog/project1$ cat plain.txt
The mountain ate the dog, AND HOW!
lab46:~/src/cprog/project1$ 

Reflection

Comments/thoughts generated through performing the project, observations made, analysis rendered, conclusions wrought. What did you learn from doing this project?

References

In performing this project, the following resources were referenced:

  • URL1
  • URL2
  • URL3 (provides useful information on topic)
  • URL4

Generally, state where you got informative and useful information to help you accomplish this project when you originally worked on it (from Google, other wiki documents on the Lab46 wiki, etc.)

haas/spring2018/cprog/projects/secretagent.txt · Last modified: 2012/09/10 01:09 by 127.0.0.1