This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:fall2015:cprog:projects:sam0 [2015/10/27 17:57] – [Function prototype] wedge | haas: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 | + | Your program(s) should: |
+ | | ||
+ | | ||
+ | | ||
+ | * obtain the signed char key value from the command-line, | ||
+ | * if neither command-line nor key file are available, display error and exit | ||
+ | * appropriately " | ||
+ | * 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: | ||
</ | </ | ||
+ | Without command-line nor cipher.key file: | ||
+ | <cli> | ||
+ | lab46: | ||
+ | ERROR: key not found | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | With 4 in the cipher.key file: | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | hello there | ||
+ | lipps xlivi | ||
+ | ^D | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | With 4 in the cipher.key file, decoding previous message: | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | lipps xlivi | ||
+ | hello there | ||
+ | ^D | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | Via positive command-line key, decoding: | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | jgnnq | ||
+ | hello | ||
+ | ^D | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | You can also save typing, by providing your input via a here string (also a nice way to check for EOF): | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | hello | ||
+ | lab46: | ||
+ | </ | ||
=====Submission===== | =====Submission===== | ||
To successfully complete this project, the following criteria must be met: | To successfully complete this project, the following criteria must be met: |