Description
1. Break the Cypher (30 marks) This question involves extracting data that has been encrypted by us using the Reverse Caesar Cypher algorithm. That is: void encrypt( unsigned char *source, int source_len, int key ); – Assumes character values are unsigned integers in the range 0-255 – For each character, adds key, wrapping around so that 256 becomes 0 – Reverses the order of the characters within the string – Examples: – Input “a” with key 5 goes to “f” – Input “9” with key 10 goes to “C” – Input “a9” with key 3 goes to “<d” (part=”” a)=”” write=”” a=”” program=”” “q1a_decrypt.c”=”” that=”” takes=”” 2=”” command-line=”” arguments:=”” (1)=”” an=”” integer=”” key;=”” and=”” (2)=”” path=”” to=”” file=”” containing=”” string=”” data=”” has=”” been=”” encrypted=”” using=”” the=”” reverse=”” caesar=”” cypher=”” algorithm.=”” your=”” must=”” output=”” decrypted=”” (original)=”” as=”” standard=”” out,=”” followed=”” by=”” newline.=”” note=”” message=”” should=”” only=”” read=”” properly=”” when=”” correct=”” key=”” is=”” provided=”” (this=”” “security”=”” given=”” encryption=”” algorithm).=”” run=”” with=”” wrong=”” key,=”” will=”” be=”” unreadable=”” or=”” even=”” contain=”” non-printing=”” characters,=”” newlines,=”” null=”” characters=”” etc.=”” all=”” sample=”” files=”” include=”” “null”=”” character=”” last=”” byte=”” in=”” -=”” you=”” make=”” sure=”” not=”” interpret=”” this=”” part=”” of=”” (i.e.,=”” do=”” shift=”” it).=”” maximum=”” size=”” we=”” use=”” during=”” marking=”” 1000=”” characters.=”” b)=”” assumption=”” about=”” original=”” (such=”” it=”” english=”” text),=”” possible=”” “crack”=”” simple=”” schemes=”” such=”” cypher,=”” without=”” needing=”” key.=”” brute-force=”” approach=”” decrypt=”” repeatedly=”” many=”” keys=”” until=”” desired=”” properties.=”” for=”” question,=”” life=”” easier=”” guarantee:=”” their=”” filename=”” ranges=”” a-z,=”” spaces=”” null-terminators=”” (\0).=”” they=”” at=”” least=”” one=”” (a=”” (z=”” z).=”” “q1b_crack.c”=”” 1=”” argument:=”” data.=”” lines=”” output:=”” was=”” found=”” search=”” resulting=”” running=”” $=”” .=”” crack=”” happy_halloween.crypt=”” print:=”” 200=”” arent=”” scared=”” these=”” daze=”” used=”” b=”” always=”” follow=”” stated=”” guarantee.=”” have=”” handle=”” 2.=”” matt’s=”” chat=”” daemon=”” (50=”” marks)=”” c=”” “q2_text_chat.c”=”” implements=”” turn-based=”” system.=”” user=”” interactions=”” occur=”” terminal=”” i=”” o=”” passed=”” between=”” processes=”” plain-text=”” files.=”” can=”” communicate=”” messages,=”” cannot=”” networking=”” other=”” system=”” calls.=”” follows:=”” q2_text_chat=”” <incoming_file=””> The program must begin by checking for an existing message in . If the incoming file does not exist yet, or if it does not hold a valid message, you must print the line “Nothing received yet.” If a valid message exists, your program should print one line of terminal output of the form: Received: The rest of the program continues by alternating 1 send and then 1 receive forever until or are pressed – this defines turn-based behaviour. To send, the user must be prompted for a message by printing “Send: “ on the terminal, and waiting until one line of text is entered on stdin (until user hits return). Write the message into as “[] ”. To receive, check for new messages in . That is, keep track of the previous message that was printed to screen and keep monitoring the file forever until the message in differs from the previous one. When a new message does arrive, display it using “Received: ”. It is OK not to print the same message twice, even if the other user tries to repeat. Note that 2 processes of this program are required to achieve meaningful “chatting”. In order to chat properly, the of one process must match the of the other process, and vice-versa. Make sure to apply appropriate checking on arguments, file inputs and terminal inputs to ensure your program always works as expected and does not crash. Sample chat session: 3. Private Chatting (20 marks) Write a C program that combines the previous two pieces of functionality by implementing an encrypted chat system that uses the Reverse Caesar Cypher. Your program must take 4 arguments: $ ./q3_encrypted_chat All the same chat interactions from Question 2 must also be used here so that the users of the chat do not experience any change due to the encryption. When and are inspected during the chatting process, all data stored in the files must be encrypted properly using the Reverse Caesar Cypher. This can be tested by running the program from Question 1a. e.g., $ ./decrypt 3 a.txt -> must print the latest chat message sent, in readable form. As you are reusing functionality from Q1 and Q2, you may choose to reuse your previously written files as objects or libraries or to recreate the functionality independently for Q3. This is your choice. However, you must provide a “CMakeLists.txt” file that allows us to compile your solution for Q3 using the the following commands (relative to the submission directory): $ mkdir build $ cd build $ cmake .. $ make $ ./q3_encrypted_chat (the chat starts correctly…) Submitting your solutions: You will submit a single zip file that contains all of the C files and the CMakeLists.txt holding your solutions. Create the zip file with the command: $ zip A3_solutions.zip q1a_decrypt.c q1b_crack.c q2_text_chat.c CMakeLists.txt The TAs will mark your code by compiling it, and running several different test cases. It must compile without errors and produce an output program to be awarded any marks, so test carefully at Trottier as always. Remember to include a reasonable level of code comments and run-time error checking.</d”>