You are on page 1of 5

caesar cipher Caesar cipher

In cryptography, a Caesar cipher, also known as Caesar's cipher,


the shift cipher, Caesar's code or Caesar shift, is one of the simplest
and most widely known encryption techniques. It is a type of substitution
cipher in which each letter in the plaintext is replaced by a letter some
fixed number of positions down the alphabet. For example, with a left The action of a Caesar cipher is
shift of 3, D would be replaced by A, E would become B, and so on. The
method is named after Julius Caesar, who used it in his private to replace each plaintext letter
correspondence.[1] with a different one a fixed
The encryption step performed by a Caesar cipher is often incorporated number of places down the
as part of more complex schemes, such as the Vigenère cipher, and still alphabet. The cipher illustrated
has modern application in the ROT13 system. As with all single-alphabet
substitution ciphers, the Caesar cipher is easily broken and in modern
here uses a left shift of three, so
practice offers essentially no communications security. that (for example) each
occurrence of E in the plaintext
becomes B in the ciphertext.
Example
The transformation can be represented by aligning two alphabets; the
cipher alphabet is the plain alphabet rotated left or right by some number
of positions. For instance, here is a Caesar cipher using a left rotation of
three places, equivalent to a right shift of 23 (the shift parameter is used
as the key):

When encrypting, a person looks up each letter of the message in the "plain" line
and writes down the corresponding letter in the "cipher" line.

Caesar cipher
MATLAP Application

Script code in matlap:

Code:
%% caesar cipher
Plaintext= input('Plaintext: ','s')
%% text the user want to encrypt
Shift= input('Shift: ')
%% user choose the number of shift
Output = Plaintext+Shift;
r=Output-26;

for i = 1:length(Plaintext)

if Output(i) <= 30
Output(i) = char(Output(i));

else
Output(i) = char(r(i));
end
end
fprintf('Ciphertext: ','s')
disp(char(Output))
Run:

EX(1):
When we entered (plaintext) :

Plaintext = ' salman '

And the (shift ) :

Shift = 15

Ciphertext: hVabVc

Note: we have space in the text 'salman '


EX(2):
When we entered (plaintext) :
Plaintext = ' salman '

And the ( shift ) :

Shift = 15

Ciphertext : hVabVc

Note: here we don't have space in the text 'salman'

Summary:
The Different between ex 1 and ex 2 :

same the shift for ex1 and ex2 , like that plaintext but for ex1 we did space in word end

if I enter plaintext = hvabvc and same the shift he gives the ciphertext = salman

but if change any plaintext or shift the output for ciphertext is different
References:

• "Caesar Cipher". Wikipedia, 13 oct ،2022. Wikipedia,


https://en.wikipedia.org/w/index.php?title=Caesar_cipher&oldid=1115923163.

You might also like