Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB take a screenshot 12. Optional: Write a simple shuffling 'encryption' algorithm. a. b. c. Next, let's shuffle the indices of the letters. To do

image text in transcribed

MATLAB take a screenshot

12. Optional: Write a simple shuffling 'encryption' algorithm. a. b. c. Next, let's shuffle the indices of the letters. To do this, we need to make a string of Open a new script and save it as encrypt.m At the top of the script, define the original string to be: This is my top secret message! encoding indices i. Make a vector that has the indices from 1 to the length of the original string in a randomly permuted order. Use randperm and length ii. Encode the original string by using your encoding vector as indices into original. Name the encoded message encoded d. Now, we need to figure out the decoding key to match the encoding key we just made. i. Assemble a temporary matrix where the first column is the encoding vector you made in the previous part and the second column are the integers from 1 to the length of the original string in order. Use length, and you may need to transpose some vectors to make them columns using ii. Next, we want to sort the rows of this temporary matrix according to the values ii. After it's been sorted, extract the second column of the temporary matrix. This iv. To make the decoded message, use the decoding vector as indices into in the first column. Use sortrows. is your decoding vector encoded e. Display the original, encoded, and decoded messages Display the following three strings, where: original , encoded, and decoded are the strings you made above. Use disp Original: original Encoded: encoded Decoded: decoded i. f. Compare the original and decoded strings to make sure they're identical and display the result i. Use strcmp to compare the original and decoded strings. Name the output of this operation correct. correct will have the value 1 if the strings match and the value 0 if they don't ii. Display the following string: Decoded correctly (1 true, 0 false: correct use disp and num2str g. Run the script a few times to verify that it works well. You should see an output like this: >encrypt Original: This is my top secret message! Encoded sisrpigct tessaoheem m Tse! DecodedThis is my top secret message! Decoded correctly (1 true, false) 1 12. Optional: Write a simple shuffling 'encryption' algorithm. a. b. c. Next, let's shuffle the indices of the letters. To do this, we need to make a string of Open a new script and save it as encrypt.m At the top of the script, define the original string to be: This is my top secret message! encoding indices i. Make a vector that has the indices from 1 to the length of the original string in a randomly permuted order. Use randperm and length ii. Encode the original string by using your encoding vector as indices into original. Name the encoded message encoded d. Now, we need to figure out the decoding key to match the encoding key we just made. i. Assemble a temporary matrix where the first column is the encoding vector you made in the previous part and the second column are the integers from 1 to the length of the original string in order. Use length, and you may need to transpose some vectors to make them columns using ii. Next, we want to sort the rows of this temporary matrix according to the values ii. After it's been sorted, extract the second column of the temporary matrix. This iv. To make the decoded message, use the decoding vector as indices into in the first column. Use sortrows. is your decoding vector encoded e. Display the original, encoded, and decoded messages Display the following three strings, where: original , encoded, and decoded are the strings you made above. Use disp Original: original Encoded: encoded Decoded: decoded i. f. Compare the original and decoded strings to make sure they're identical and display the result i. Use strcmp to compare the original and decoded strings. Name the output of this operation correct. correct will have the value 1 if the strings match and the value 0 if they don't ii. Display the following string: Decoded correctly (1 true, 0 false: correct use disp and num2str g. Run the script a few times to verify that it works well. You should see an output like this: >encrypt Original: This is my top secret message! Encoded sisrpigct tessaoheem m Tse! DecodedThis is my top secret message! Decoded correctly (1 true, false) 1

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

Step: 3

blur-text-image

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

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions