Answered step by step
Verified Expert Solution
Question
1 Approved Answer
!!!URGENT!!! please read the question properly and give the full answer correctly. wrong or incomplete answers will be reported! Problem Description Bob and Alice want
!!!URGENT!!!
Problem Description Bob and Alice want to send mesuges to each othec but want to make sue that no one else can understand their messages They decide on a secret scheme to exchange ary data they send to each other lie. a cipher as follows: - They will ceate a mopping scheme that maps each lether in the plivintest alphabet to a different ierser in the ciphertext alphabet. Letters can appear in any order in the mapping seteme but there should be a botal of 26 distinct letters in both alphobets For exachple the following mapping s puret, is a valid 1/7 Aasignmentl_descrptonnd s.0020a3 mapping scheme, where the plaintext alphabet appeas before the comma and the ciphertert aphabet appears after the comma. a,pb,hc,4d,b++ and the following mapping. suppinel, where plantest slphabet does not appear in order, is also valit: d,fb,5x,ye,tm,0t,y0,0n,h - The following are the steps taken to encrypt a plainted word. For each letter in the word, replace that letter with the comesonding letter from the ciphenteat alphabet according to the input mapping scheme. - Once all the letters in the word are encrypted, output the iesult in revese onter. - The following are the steps taken to decrypt a given ciphertent wont: - For each letter in the ciphertext woid, replace that letser with the comesponding leter from the plaintest alphabet acconding to the input mapping scheme. - Once all the letters in the word are decrypted, ousput the rewit in revene order. Task Write a program that implements the above encryption and decryetion scteme. How to nun your program Your program runs as follow: where - moppinghile as a comme separated tile foced as shom abose and s prected by the fag : - encyption mode determices a the program should exiyst or ilengt the input provided by the user. The mode is i for encyption and 2 for decryption. The moder is precodied ty the flag - inputele in a teat ingut file that concaiss the lier of wirta thie an going to le esoryened er decrypted. Fach woud appears on a separase line The flie is precasiod try the flug tagsi. - Note that the enter of the paogram engumeints ihould noe mume fer mam ele the following are at eguivalent ways to tuin the propram and will yuld the uine behaver. Error Checking that needs to be returned in each caie. The ieturt code is the intsget that your program inturns ipon eit indicate placehelden and mat be replaced by the ruact arpumeit. Acth the quecationt ind the ingle brackets should not be induded in the mesugeli * if the inpultile - Erer Message "tror: Mapping tile eName of mupping files does not exitt" a feturn code: 3 eactly 26 lines (2) each line has the formar nepeated leners in either alphabets and 14, all 26 leten of the Englob aphabet appear in both the plaietent and ciphertent alphabent. - Erer Message "Error The fermat of mapping file eName of mapeing files is incareect" 4 Retum code: 4 - if the inpul tile suruitilis is nee foubd. - Iror Messege "Error input word fille ethane of lnput flies does not rabst" - Retuen code: 5 . - If the unet parses in an inconect mode ale. avy mode deter Pat 7 er 21 . - tiror Mesaage "Vou entered cvalue of incenset modes, Somp. your mode must be 1 for eneryption ee 2 fer decryption" a) Reluen code: 6 13arewa - For any other incolrect invocitions of the propam ir g. mald ag ments, ebra argynets, or not providing the required argumenck: - Enor Mesage "Uuage: denerypt - emappingfiles -im eencryption medes - e einputfiles" - Return code: 7 Expected Output - Depending on the mode entered, the following wil haen - for mode 1 . - The program ensrypti each irput word in the pien ia a tritio in the same order they uppex, and outpuas the result on the soten Emb loe in the input Gir caneigondi to a Ine is the output Make sure te primt io it s. At and net to include any ipsces after the eutput werd en each lise. program must intum 0 en succeath mampleten For mode 2 - The program will decrypt each input ciphertext word in the given I ppusfilis and output the result on the screen. Each line in the input file corresponds to a line in the output. Make sure to print to stdeut and not to include any spaces after the output word on each line. - Once the program finishes processing the input list of words, it will exit. Note that your program must return 0 on successtul completion. Please do not include any extra messages or debugging information. Any extra output will make your output different from the expected output, and will cause you to fail the test cases. Program Format - Your program consists of a single C file called encrypti.c - Your program must contain at least three functions (the ma in function and two additioral functions). You can choose how you will modularaize your program (i.e, which functionality you will indude in these two functions). Your functions must make sense and represent a coherent functionaliy fie, it your two functions are just 2 lines each, that's not really proper modularization). Aemember to propenly declare your functions at the beginning of the file. - You are welcome (and encouraged) to have more functions to have a cleaner and more modular program, but the above three functions are the minimum that will count towards your grade. To get started early, you can just create the main function that contains all your code. When we cover functions, you can then create two additional functions, and take out the necessary parts of the code you wrote to put into these functions. Do not wait till we cover functions to start this assignment. It is unlikely that you will finish it on time. - While we will not grade you for header files for this assignment, you are weicome (and encouraged) to create a header file for your program. - Please check the general assignment information on eClass for code style, comments, etc. Assumptions Assignment1_description.md 1302023 The following are assumptions you can safely make. You cannot assume amything that is not explictly stated here. When in doubt, ask on the forum, - The input files we will use to test your program will follow the correct format indicated above - Our test input files will have words that contain only lower-case English letters. Each word will be on a separate line in the input file, and the maximum length of any word is 20 letters - We will only test with input that can be encrypted/decrypted using the corresponding input mapping file we use. - You cannot make any assumptions about the input mapping file. You must ensure that it is in the correct format descnbed above. - You cannot make any assumptions about the program arguments. You must ensure you handie all cases described in the "How to run your program" section above. When testing your program arguments, we will make sure the expected output of the test case is not ambiguous and corresponds to one cutput code. - For mode 2 - The program will decrypt each input ciphertext word in the given inputilin and output the result on the screen. Each line in the input file corresponds to a line in the output. Make sure to print to stdiout and not to include any spaces after the output word on each line. - Once the program finishes processing the input list of words, it will exit. Note that your program must return 0 on successful completion. Please do not include any extra messages or debugging information. Any extra output will make your output different from the expected output, and will cause you to fail the test cases. Program Format - Your program consists of a single C file called encrypti.c - Your program must contain at least three functions (the eutin function and two additional functions). You can choose how you will modularaize your program (i.e, which functionality you will include in these two functions). Your functions must make sense and represent a coherent functionality (i.e, if your two functions are just 2 lines each, that's not really proper modularization). Remember to properly declare your functions at the beginning of the file. - You are weicome (and encouraged) to have more functions to have a cleaner and more modular program, but the above three functions are the minimum that will count towards your grade. To get started early. you can just create the main function that contains all your code. When we cover functions, you can then create two additional functions, and take out the necessary parts of the code you wrote to put into these functions. Do not wait till we cover functions to start this assignment. It is unlikely that you will finish it on time. - While we will not grade you for header filles for this assignment, you are welcome (and encouraged) to create a header file for your program. - Please check the general assignment information on eClass for code style, comments, etc. Assumptions Assignment1_descripsion md 1130/2023 The following are assumptions you can safely make. You cannot assume anything that is not explicitly stated here. When in doubt, ask on the forum. - The input files we will use to test your program will follow the correct format indicated above: - Our test input files will have words that contain only lower-case English letters. Each word will be on a separate line in the input file, and the maximum length of any word is 20 letters. - We will only test with input that can be encrypted/decrypted using the corresponding input mapping file we use. - You cannot make any assumptions about the input mapping file. You must ensure that it is in the correct format described above. - You cannot make any assumptions about the program arguments. You must ensure you handle all cases described in the "How to run your program" section above. When testing your program arguments, we wil make sure the expected output of the test case is not ambiguous and corresponds to one output code please read the question properly and give the full answer correctly. wrong or incomplete answers will be reported!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started