Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CoursHeroTranscribedText: COP2271 MATLAB Spring 2016 Assignment 5 Due: February 26 (Friday) at 11:59 pm Polybius Square Cipher Decryption Implement a decryption cipher to decode messages
CoursHeroTranscribedText: COP2271 MATLAB Spring 2016 Assignment 5 Due: February 26 (Friday) at 11:59 pm Polybius Square Cipher Decryption Implement a decryption cipher to decode messages from text les. Key programming concepts: if statements, loops, strings, le input Approximate lines of code: 30 (does not include comments or white space) Program Inputs and Outputs Display to the user the following information/questions: Enter le to decrypt: - The user will always enter a le that exists and needs to be decrypted and your program must display the answer as: Decrypted message: XXX where XXX is the decrypted message for every line in the chosen le Assignment Details: This assignment will give you a brief introduction into cryptography using the Polybius Square Cipher! Cryptography allows us to encode and decode messages that are dicult to decipher without knowledge of a secret key/table/code. Cryptography is a rich subject in its own right, but we will not have time to cover it in detail. Please check out the numerous online resources if you want more information. This particular cipher depends upon the following secret table, which has the 26 letters from the alphabet along with 10 common punctuation marks, randomly arranged in a 6 by 6 grid: 1 2 3 4 5 6 1 R ) V J ; S 2 K L D W A Q 3 Y N T ? G " 4 : P ( X U ' 5 . , ! Z B M 6 H F E I C O The main idea is to replace letters in your secret message with the corresponding row and column number from the table. The encrypted message will then have two numbers that represent a single letter. For example, lets encrypt the following message: ATTACK AT DAWN 1 COP2271 MATLAB Spring 2016 Assignment 5 Due: February 26 (Friday) at 11:59 pm Letter Corresponding Number A 25 T 33 C 65 K 21 D 23 W 24 N 32 The individual letters from the message correspond to the following numbers: Putting these numbers together, gives us the following encoded message: 253333256521 2533 23252432 To decode the message, you just do the reverse process! Given two numbers, use the rst number as the row and the second as the column in the polybius grid to nd the corresponding letter. Sample Output The following test cases do not cover all possible scenarios (develop your own!) but should indicate if your code is on the right track. Canvas has three le for you to test: Decrypt 1.txt, Decrypt 2.txt, and Decrypt 3.txt. Each le contains a famous movie quote that needs decrypting! Test Case 1: Enter file to decrypt: Decrypt_1.txt Decrypted message: THE INCREDIBLES LUCIUS: HONEY? HONEY: WHAT? LUCIUS: WHERE'S MY SUPER SUIT? HONEY: WHAT? LUCIUS: WHERE IS MY SUPER SUIT? HONEY: I, UH, PUT IT AWAY. Test Case 2: Enter file to decrypt: Decrypt_2.txt Decrypted message: INDEPENDENCE DAY AND SHOULD WE WIN THE DAY, THE FOURTH OF JULY WILL NO LONGER BE KNOWN AS AN AMERICAN HOLIDAY, BUT AS THE DAY THE WORLD DECLARED IN ONE VOICE: "WE WILL NOT GO QUIETLY INTO THE NIGHT!" WE WILL NOT VANISH WITHOUT A FIGHT! WE'RE GOING TO LIVE ON! WE'RE GOING TO SURVIVE! TODAY WE CELEBRATE OUR INDEPENDENCE DAY! 2 COP2271 MATLAB Spring 2016 Assignment 5 Due: February 26 (Friday) at 11:59 pm Test Case 3: Enter file to decrypt: Decrypt_3.txt Decrypted message: A FEW GOOD MEN JESSEP: I'LL ANSWER THE QUESTION. YOU WANT ANSWERS? LIEUTENANT KAFFEE: I THINK I'M ENTITLED TO THEM. JESSEP: YOU WANT ANSWERS?! LIEUTENANT KAFFEE: I WANT THE TRUTH! JESSEP: YOU CAN'T HANDLE THE TRUTH! Key Ideas To Consider You need to nd a way enter the Polybius table as a variable in MATLAB; one approach is to unroll the table into one long string by writing all the rows next to each other. You could also just directly enter the table as a matrix. Understanding the dierence between physical numeric values and numbers that appear in strings is crucial! For example, the number value 5 is not the same as the string '5'. Converting between numbers and strings is done with the str2num and num2str functions: - str2num - Use str2num to convert any string to a physical numeric value. You can index the string rst to convert only part of the string. - num2str - Takes any numeric value and returns the same value a string. There are numerous ways to read les in MATLAB; one approach is the fopen, fgetl, and fclose commands. 3
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