You are on page 1of 3

Introduction to Cyber Security

EE4330

Name&ID:
Salman Alhaqbani
436051282
Ibrahim Alhabib
436051644
Caesar cipher

example:

Plaintext: salman

= Plaintext

'salman'
Shift: 15

= Shift
15

Ciphertext: hVabVc

Explained:
We enter in plaintext: salman and the shift we used : 15
Ciphertext output is = hvabvc
Note: if I enter plaintext = hvabvc and same the shift he give the output = salman
but if change any plaintext or shift the output for ciphertext is different
like this example:

Plaintext: electrical engineering


Shift: 2
= Plaintext

'electrical engineering'
Shift: 2

= Shift
2

Ciphertext: MTMK\ZQKIMVOQVMMZQVO

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))

You might also like