Search
Ask a question
0 0

Caesar cipher

. Using a Caesar cipher decrypt the following message and determine the key used. (Hint: KU is repeated , Alphabet wraps around)
VJKU SWKB KU QXGT
Tutors, please sign in to answer this question.

2 Answers

MATLAB CODE
 
mymessage = 'VJKU SWKB KU QXGT';
%This is the message to be encoded or decoded by shifting x alphabet units.
x = input('x= ');
%x is the number of alphabet units the message will be shifted by.
%Encoding Script
while x~=99;


   x = mod(x,26);
   for i = 1:size(mymessage,2);
      tempnumber = double(mymessage(1,i));
      if tempnumber == 32;%do not shift spaces
      else
         tempnumber = tempnumber+x;%shift
      end
      if tempnumber>90;%Wrap around
         tempnumber = tempnumber-90+64;
      end
      mymessage(1,i) = char(tempnumber);
   end
   disp(mymessage);
   x = input('x= ');
end
 
 
 
What x's would you attempt?
 
Try x =24, -2...
Note modulus 26, 24 and -2 are the same

Comments

“Using a Caesar cipher decrypt the following message and determine the key used: VJKU SWKB KU QXGT.”

You can also use a spreadsheet; e.g., http://www.wyzant.com/resources/files/265747/caesar_cipher.

Functions used: VLOOKUP and MOD.