function message = caesar(message,shift)

% CAESAR Performs Caesar-cipher shifts on message text
%
% CAESAR(message,'encipher'): enciphers message
% CAESAR(coded,'decipher'): deciphers coded text
% CAESAR(message,x): shifts the message letters by the amount x

% interpret inputs
if (nargin < 2)
    shift = 3;
elseif ischar(shift)
    if strcmp(shift,'encipher')
        shift = 3;
    else
        shift = -3;
    end;
end;

% perform the shift
uc = (message>=65)&(message<=90);
lc = (message>=97)&(message<=122);
message(uc) = mod(message(uc)-65+shift,26)+65;
message(lc) = mod(message(lc)-97+shift,26)+97;
end
