Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ENGR 1204 Programming Languages in Engineering MATLAB Lab 7 The objective of this lab is to encrypt and decrypt the message (string) below: THIS IS

image text in transcribed
image text in transcribed
ENGR 1204 Programming Languages in Engineering MATLAB Lab 7 The objective of this lab is to encrypt and decrypt the message (string) below: THIS IS A SECRET MESSAGE Write a MATLAB program (M script file) which enables you to input the message and create an encrypted message by replacing each letter (not the spaces) using a "random shift". That is, the ASCII code for the letter is increased by a random amount. Here's an example: PRESS word in message 3 167 21 5 vector of "random" integers in range 1 to 25 SHLNX encrypted word Note: 'P is advanced by 3 places to become 'S R' is advanced by 16 places to become 'H' (ie. after 'Z', start again with 'A), etc. By decreasing the letters of the encrypted message by the same random vector, the original message can be recovered. It is recommended you use for loops and if structures for encryption and recovery. Before running the program, initialize the random seed in the command mode to your student ID: lwA8ea number. Then run the program three times without resetting the seed each time. You should observe different encrypted messages for each run, but recovery of the original message each time.-Then, create your own message and repeat the three runs. Here is a recommended start to the program and sample output for two runs. Use the same variable x for the encrypted message also. Note the random shift vector (e) for the second run. x - input(Enter message using upper case and single quotes:; m- length(x); e-randi( [1,25], 1, m); %Shift letters by random amounts vector of random integers, from 1 to 25 % Note: Generates % Encrypt message for i-1:m >>ng(1234567) >>Lab7_sp14 message using upper case and single quotes: THIS IS A SECRET MESSAGE Encrypted message: ZUA NY S XDRJDK RACCOYZ Recovered message: THIS IS A SECRET MESSAGE Lab7 sp14 Enter message using upper case and single quotes: THIS IS A SECRET MESSAGE Encrypted message: XJEY RT G CTZEND WZGTHLK Recovered message: THIS IS A SECRET MESSAGIE >> disp(e)> 4 2 22 6 19 9 1 10 6 12 10 15 23 13 9 10 22 10 21 14 1 75 6

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

More Books

Students also viewed these Databases questions

Question

What is Skinnerian conditioning? Name and describe its components.

Answered: 1 week ago