User Tools

Site Tools


haas:fall2015:cprog:projects:sam0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
haas:fall2015:cprog:projects:sam0 [2015/10/27 17:57] – [Function prototype] wedgehaas:fall2015:cprog:projects:sam0 [2015/10/29 12:26] (current) – [Sample execution: encode] wedge
Line 26: Line 26:
   * encoding - taking the readable text and making it obfuscated, according to a set process   * encoding - taking the readable text and making it obfuscated, according to a set process
   * decoding - taking the obfuscated text and making it readable, by reversing the process   * decoding - taking the obfuscated text and making it readable, by reversing the process
-=====Task=====+=====Program=====
 You are to implement two programs (or at least a program with two fundamental modes of operation): You are to implement two programs (or at least a program with two fundamental modes of operation):
   * encode program: takes plain text message as input, along with a cipher key, and outputs the encoded (obfuscated) result   * encode program: takes plain text message as input, along with a cipher key, and outputs the encoded (obfuscated) result
Line 37: Line 37:
 You can implement this as two separate programs, or as one program that behaves fundamentally different depending on how it is named (ie **encode-sam0** operates in encode mode, **decode-sam0** operates in decode mode). You can implement this as two separate programs, or as one program that behaves fundamentally different depending on how it is named (ie **encode-sam0** operates in encode mode, **decode-sam0** operates in decode mode).
  
-Your program should accept input from **STDIN** until the **EOF** character is encountered.+Your program(s) should
 +  load the provided input (via STDIN) into an array for processing (you may want to check for an EOF character to terminate input) 
 +    you may assume a maximum input size of 4096 bytes 
 +    use the **fgetc()** function instead of **fscanf()** for reading input from STDIN 
 +  * obtain the signed char key value from the command-line, if present, or read from the 'cipher.key' file 
 +    * if neither command-line nor key file are available, display error and exit 
 +  * appropriately "shift" the alphabet according to the key (magnitude and direction and mode), storing the results in an array 
 +  * for encoding, display the resultant enciphered string to STDOUT 
 +  * for decoding, display the resultant deciphered string to STDOUT
  
 ====Sample execution: encode==== ====Sample execution: encode====
Line 60: Line 68:
 </cli> </cli>
  
 +Without command-line nor cipher.key file:
  
 +<cli>
 +lab46:~/src/cprog/sam0$ ./encode-sam0
 +ERROR: key not found
 +lab46:~/src/cprog/sam0$ 
 +</cli>
 +
 +With 4 in the cipher.key file:
 +
 +<cli>
 +lab46:~/src/cprog/sam0$ ./encode-sam0
 +hello there
 +lipps xlivi
 +^D
 +lab46:~/src/cprog/sam0$ 
 +</cli>
 +
 +With 4 in the cipher.key file, decoding previous message:
 +
 +<cli>
 +lab46:~/src/cprog/sam0$ ./decode-sam0
 +lipps xlivi
 +hello there
 +^D
 +lab46:~/src/cprog/sam0$ 
 +</cli>
 +
 +Via positive command-line key, decoding:
 +
 +<cli>
 +lab46:~/src/cprog/sam0$ ./decode-sam0 2
 +jgnnq 
 +hello
 +^D
 +lab46:~/src/cprog/sam0$ 
 +</cli>
 +
 +You can also save typing, by providing your input via a here string (also a nice way to check for EOF):
 +
 +<cli>
 +lab46:~/src/cprog/sam0$ ./decode-sam0 2 <<< "jgnnq" 
 +hello
 +lab46:~/src/cprog/sam0$ 
 +</cli>
 =====Submission===== =====Submission=====
 To successfully complete this project, the following criteria must be met: To successfully complete this project, the following criteria must be met:
haas/fall2015/cprog/projects/sam0.1445968672.txt.gz · Last modified: 2015/10/27 17:57 by wedge