Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve using matlab and conditional statements(if, elseif, else) . To receive a thumbs up DO NOT USE ITERATIONS(aka Loops), upper, lower, unique, or sort

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedPlease solve using matlab and conditional statements(if, elseif, else). To receive a thumbs up DO NOT USE ITERATIONS(aka Loops), upper, lower, unique, or sort functions in the solution code!!!

Function Description: The eponymous caesar cipher is one of the most widely known encryption techniques. To use it you simply shift the alphabet left by a certain number of characters, wrapping back around to the end, and then replace all the letters with their new equivalents. A shift of 1 would see A become B, B become c, and so on until Z becomes A. A shift of 2 would have A become C, B become D, and so on until Z becomes B. Unfortunately, this cipher is easily decrypted as there are only 25 possible ways to encrypt a message with it. (Replacing A with A does not actually encrypt a message.) As such there have been multiple variations of the caesar cipher developed, many of which use a keyword in addition to a shift number, including the one you will implement in MATLAB. Write a function that decrypts an encrypted message input 1). Given the encrypted keyword (input 2), perform the following steps to obtain the decrypted keyword. 1. Make all letters lowercase and remove all punctuation, numbers, and spaces. 2. Remove repeated letters. 3. Perform a simple caesar cipher with the given shift number (input 3). Next, declare two new variables which we will call shiftA and shifts. Assign the positive distance between the first and last characters to shifta. Assign the positive distance between the second and second-to-last characters to shifts. For example, if your decrypted keyword is: decKeyword hellothere then: shifta shifts If shiftA ends up equaling zero, use the value 1 for shiftA. Likewise, if shifti ends up equalling zero, use the value 2 for shiftB. Depending on the most common letter in the decrypted keyword, each shift number will be applied to different parts of the original message in another simple caesar cipher. If the most common letter in the resulting decrypted keyword is... ... a consonant and an odd alphabetical character (c is #3 in the alphabet, so it is odd) use shifta on the odd indices of the encrypted message and shifts on the even indices. ... a consonant and an even alphabetical character (b is #2 in the alphabet, so it is even), apply shiftA to every odd character in the encrypted message and shifts on the even ones. In this case, if one shift number is even and the other odd, double the odd one. a vowel (not including y), the first half of the encrypted message will be decrypted with shifta, and the second half of the encrypted message will be decrypted with shiftB. Should the message be of odd length, the halfway point is determined by whichever character next to the middle one is larger, with the corresponding side containing the middle character. For example, if the message is: msg 'gibberish' Compare the b to the r. Since r is "greater" than b, the e goes to the second half: first Half secondHalf 'gibb 'erish' Do not forget to recombine the two halves of the message. The resulting string, once these operations are performed, is your decrypted message. Output this along with the decrypted keyword. Example: encMsg = 'Tfobuvt Qpqvmaywak Xusgtay' key = 'U!rr pp.352453xxox.xvv' shift = 3 [decMsg, key] = romanHoops (encMsg, key, shift) key 'romulus' decMsg 'Senatus Populusque Romanus' . Notes: Do not change any of the capitalization of punctuation when performing a caesar cipher A and C are odd alphabetical characters, while B is even. B is larger than A while smaller than C. These pattern/trend hold throughout the alphabet The shift number will never be negative Every keyword will have at least 4 unique letters There will never be a tie between which letters in the keyword are the most common Letters in the keyword will never repeat more than once . Function Description: The eponymous caesar cipher is one of the most widely known encryption techniques. To use it you simply shift the alphabet left by a certain number of characters, wrapping back around to the end, and then replace all the letters with their new equivalents. A shift of 1 would see A become B, B become c, and so on until Z becomes A. A shift of 2 would have A become C, B become D, and so on until Z becomes B. Unfortunately, this cipher is easily decrypted as there are only 25 possible ways to encrypt a message with it. (Replacing A with A does not actually encrypt a message.) As such there have been multiple variations of the caesar cipher developed, many of which use a keyword in addition to a shift number, including the one you will implement in MATLAB. Write a function that decrypts an encrypted message input 1). Given the encrypted keyword (input 2), perform the following steps to obtain the decrypted keyword. 1. Make all letters lowercase and remove all punctuation, numbers, and spaces. 2. Remove repeated letters. 3. Perform a simple caesar cipher with the given shift number (input 3). Next, declare two new variables which we will call shiftA and shifts. Assign the positive distance between the first and last characters to shifta. Assign the positive distance between the second and second-to-last characters to shifts. For example, if your decrypted keyword is: decKeyword hellothere then: shifta shifts If shiftA ends up equaling zero, use the value 1 for shiftA. Likewise, if shifti ends up equalling zero, use the value 2 for shiftB. Depending on the most common letter in the decrypted keyword, each shift number will be applied to different parts of the original message in another simple caesar cipher. If the most common letter in the resulting decrypted keyword is... ... a consonant and an odd alphabetical character (c is #3 in the alphabet, so it is odd) use shifta on the odd indices of the encrypted message and shifts on the even indices. ... a consonant and an even alphabetical character (b is #2 in the alphabet, so it is even), apply shiftA to every odd character in the encrypted message and shifts on the even ones. In this case, if one shift number is even and the other odd, double the odd one. a vowel (not including y), the first half of the encrypted message will be decrypted with shifta, and the second half of the encrypted message will be decrypted with shiftB. Should the message be of odd length, the halfway point is determined by whichever character next to the middle one is larger, with the corresponding side containing the middle character. For example, if the message is: msg 'gibberish' Compare the b to the r. Since r is "greater" than b, the e goes to the second half: first Half secondHalf 'gibb 'erish' Do not forget to recombine the two halves of the message. The resulting string, once these operations are performed, is your decrypted message. Output this along with the decrypted keyword. Example: encMsg = 'Tfobuvt Qpqvmaywak Xusgtay' key = 'U!rr pp.352453xxox.xvv' shift = 3 [decMsg, key] = romanHoops (encMsg, key, shift) key 'romulus' decMsg 'Senatus Populusque Romanus' . Notes: Do not change any of the capitalization of punctuation when performing a caesar cipher A and C are odd alphabetical characters, while B is even. B is larger than A while smaller than C. These pattern/trend hold throughout the alphabet The shift number will never be negative Every keyword will have at least 4 unique letters There will never be a tie between which letters in the keyword are the most common Letters in the keyword will never repeat more than once

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Second International Conference Acids Hue City Vietnam March 2010 Proceedings Part 1 Lnai 5990

Authors: Manh Thanh Le ,Jerzy Swiatek ,Ngoc Thanh Nguyen

2010th Edition

3642121446, 978-3642121449

More Books

Students also viewed these Databases questions

Question

a. How do you think these stereotypes developed?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago