First Bytes at the Honors Colloquium

Caesar Cipher Lab - Part 2

Introduction: In this lab activity you will use MatLab and write functions to decrypt a message that is encoded with a Caesar cipher that is known, but can vary for each message. You are creating a more general purpose deciphering tool in this lab.

This lab is available at www.cs.utexas.edu/users/scottm/FirstBytes/caesarLabPart2.htm

In the previous lab you knew ahead of time the shift was 5 and this was hard coded into your solution. What happens now if the shift is known to be 10? You could go in and change your function every time there is a new shift, but this is cumbersome, especially if the person using the program doesn't know how to program.

Instead we want to make our solution more general, meaning it can be used to solve many different types of problems. In this case we want to be able to handle different size shifts with 1 function.

Alter the function from part 1 so that the shift can be specified by the person calling the function. Add an input to the function that is the size of the shift to undo. The function header would become:

    function result = shift( message, shift )

You can use the save as file option so you don't have to retype the entire function.

There are two messages for this lab. 

The first was encoded with a shift of 10 and is:

REWKXCKBOKVVOBQSMDYMRKXQODROIVYFODYCKIGOFOKVGKICNYXOSDDRSCGKISDBIDYPSQRDDRKDDRKDCGRISRKFOKMVYMUYXWIGKVVDRKDBEXCMYEXDOBMVYMUGSCOBOKBKNWSBKVQBKMOWEBBKIRYZZOB

The second was encoded with a shift of 20 and is:

UMBCJCHJILNCMMUZYVONNBUNCMHINQBUNMBCJMULYVOCFNZILCQUHNUFFNBYSIOHAMNYLMNIMUCFIONNIMYUUHXVYAIIXMBCJMALUWYBIJJYL

The two messages are on the web at

www.cs.utexas.edu/users/scottm/FirstBytes/caesar2.txt

and

www.cs.utexas.edu/users/scottm/FirstBytes/caesar3.txt