Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve in matlab The Caesar Cipher is a simple encryption technique in which all letters are replaced by another letter a fixed number of positions

solve in matlab image text in transcribed
image text in transcribed
The Caesar Cipher is a simple encryption technique in which all letters are replaced by another letter a fixed number of positions down the alphabet. For example, a right shift of 3 on the English alphabet would result in the following: ABCDEFGHIJKLMNOPQR S T U V W X Y Z In this example, the letter M is replaced by the letter P, which is three positions to the right of M. Using this system with a right shift of 3, the string 'MATLABISFUN' would be replaced by PDWODELVIXQ'. If 'A' is encoded as 0, we can use the following equation to shift a single letter: where x is the numerical encoding of the letter, s is the Caesar Cipher shift size, and N is the numerical encoding of the new encrypted letter. (% indicates modulus division... recall the mod() function. The same equation can be used to shift every element in a vector. (Note that ASCII encodes A as 65 by default, so you need to shift your starting strings down by 65 so that A=0 before you can use this equation.) Write a MATLAB script to do the following: 1. Use dlmread to read in the shifts.txt file. 2. Use dlmread to read in all of the caesar#.txt files from Canvas inside of a loop. 3. For each "caesar#.txt" file, perform a Caesar Cipher shift according to the corresponding value in "shifts.txt." (E.g. shift the data in caesarl.txt by the number of letters given by the first value in shifts.txt.) 4. Print each decoded string (these should be letters, not numbers). 5. Convert each decoded string back to numbers, and then use dlmwrite to write each decoded string to a different text file. To build the filename, combine the first 6 characters of the decoded string, the number of the file, and the string _decoded to build each filename. For example, the first file (generated from the data in caesar 1.txt) should end up as MATLAB1_decoded.txt." Include these files when you turn in your scripts. Self-check: (These will all be recognizable English phrases) String 1: MATLAB----- String 2: U--T--F----L--E String 3: T------YG-------0-----G------- The Caesar Cipher is a simple encryption technique in which all letters are replaced by another letter a fixed number of positions down the alphabet. For example, a right shift of 3 on the English alphabet would result in the following: ABCDEFGHIJKLMNOPQR S T U V W X Y Z In this example, the letter M is replaced by the letter P, which is three positions to the right of M. Using this system with a right shift of 3, the string 'MATLABISFUN' would be replaced by PDWODELVIXQ'. If 'A' is encoded as 0, we can use the following equation to shift a single letter: where x is the numerical encoding of the letter, s is the Caesar Cipher shift size, and N is the numerical encoding of the new encrypted letter. (% indicates modulus division... recall the mod() function. The same equation can be used to shift every element in a vector. (Note that ASCII encodes A as 65 by default, so you need to shift your starting strings down by 65 so that A=0 before you can use this equation.) Write a MATLAB script to do the following: 1. Use dlmread to read in the shifts.txt file. 2. Use dlmread to read in all of the caesar#.txt files from Canvas inside of a loop. 3. For each "caesar#.txt" file, perform a Caesar Cipher shift according to the corresponding value in "shifts.txt." (E.g. shift the data in caesarl.txt by the number of letters given by the first value in shifts.txt.) 4. Print each decoded string (these should be letters, not numbers). 5. Convert each decoded string back to numbers, and then use dlmwrite to write each decoded string to a different text file. To build the filename, combine the first 6 characters of the decoded string, the number of the file, and the string _decoded to build each filename. For example, the first file (generated from the data in caesar 1.txt) should end up as MATLAB1_decoded.txt." Include these files when you turn in your scripts. Self-check: (These will all be recognizable English phrases) String 1: MATLAB----- String 2: U--T--F----L--E String 3: T------YG-------0-----G

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

Students also viewed these Databases questions