This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:skinney1:portfolio:cprogproject1 [2012/02/26 02:21] – [Objectives] skinney1 | user:skinney1:portfolio:cprogproject1 [2012/03/12 17:44] (current) – [Scope] wedge | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Project: | ||
+ | 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===== | ||
+ | Create a program that will encrypt and de-crypt a file as needed. | ||
+ | |||
+ | =====Prerequisites===== | ||
+ | In order to successfully accomplish/ | ||
+ | |||
+ | * 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/ | ||
+ | * 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? | ||
+ | |||
+ | Upon approval, you'll want to fill this section out with more detailed background information. DO NOT JUST PROVIDE A LINK. | ||
+ | |||
+ | 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 " | ||
+ | * or, if you prefer, use command-line arguments to provide the key | ||
+ | * obtains the input message from a file called " | ||
+ | * if " | ||
+ | * outputs the ciphertext message to STDOUT **AND** saves it to a file called " | ||
+ | * 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 " | ||
+ | * or, if you prefer, use command-line arguments to provide the key | ||
+ | * obtains the input cipher from a file called " | ||
+ | * if " | ||
+ | * outputs the plaintext message to STDOUT **AND** saves it to a file called " | ||
+ | * 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 c> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | FILE *in; | ||
+ | char *c, fname[] = " | ||
+ | int i; | ||
+ | int *input[255]; | ||
+ | |||
+ | printf(" | ||
+ | scanf(" | ||
+ | |||
+ | if (*input == ' | ||
+ | { | ||
+ | c = fgetc(in); | ||
+ | while(c != EOF) | ||
+ | { | ||
+ | if((c >=65) && (c <= ' | ||
+ | c++; | ||
+ | else if((c >= ' | ||
+ | c++; | ||
+ | if((c == (' | ||
+ | c = c - 26; | ||
+ | fprintf(stdout, | ||
+ | c = fgetc(in); | ||
+ | } | ||
+ | } | ||
+ | else if (*input == ' | ||
+ | { | ||
+ | c = fgetc(in); | ||
+ | while(c != EOF) | ||
+ | { | ||
+ | if((c >=65) && (c <= ' | ||
+ | c--; | ||
+ | else if((c >= ' | ||
+ | c--; | ||
+ | if((c == (' | ||
+ | c = c - 26; | ||
+ | fprintf(stdout, | ||
+ | c = fgetc(in); | ||
+ | } | ||
+ | } | ||
+ | fclose(in); | ||
+ | return (0); | ||
+ | } | ||
+ | </ | ||
+ | error from code, unable to get this to execute | ||
+ | |||
+ | <cli> | ||
+ | Do you want to encrypt the file: Y | ||
+ | Segmentation fault | ||
+ | lab46: | ||
+ | </ | ||
+ | =====Reflection===== | ||
+ | Comments/ | ||
+ | |||
+ | =====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.) |