PR 5
PR 5
I Practical significance
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 atype 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 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 correspondence
II Relevant Program Outcome (POs)
PO1 – Basic knowledge
PO2 – Discipline
knowledge
PO3 – Experiments and
practicePO4 – Life-long
learning
V Practical outcomes
Create program to implement Caesar Cipher.
Page No : 1
By Prof.R.H.Rathod, Comp.Engg. Deptt., Dr.Panjabrao Deshmukh Polytechnic, Amravati
Network and Information Security (22620)
VII Minimum Theoretical Background
The Caesar Cipher technique is one of the earliest and simplest method of encryption technique.
It’s simply a type of substitution cipher, i.e., each letter of a given text is replaced by a letter
somefixed number of positions down the alphabet. For example with a shift of 1, A would be
replaced by B, B would become C, and so on. The method is apparently named after Julius
Caesar, who apparently used it to communicate with his officials.
Thus to cipher a given text we need an integer value, known as shift which indicates the number
ofposition each letter of the text has been moved down.
The encryption can be represented using modular arithmetic by first transforming the letters into
numbers, according to the scheme, A = 0, B = 1,…, Z = 25. Encryption of a letter by a shift n
can be described mathematically as.
(Encryption Phase with shift n) (Decryption Phase with shift n)
X Precaution to be followed
a. Handle computer system and peripherals with care
b. Handle cat6 crossover cable carefully
c. Follow safety precautions
d. Disconnect PCs from these cables and shut down properly
XI Procedure
Program For Encryption:
#include<stdio.
h>int main()
{
char str_message[500],
Page No : 2
By Prof.R.H.Rathod, Comp.Engg. Deptt., Dr.Panjabrao Deshmukh Polytechnic, Amravati
Network and Information Security (22620)
ch;int j, key;
printf("Enter a message to encrypt: ");
scanf("%s",str_message);
printf("Enter the key: ");
scanf("%d", &key);
for(j = 0; str_message[j] != '\0';
++j){ch = str_message[j];
if(ch >= 'a' && ch <=
'z'){ch = ch + key;
if(ch > 'z'){
ch = ch - 'z' + 'a' - 1;
}
str_message[j] = ch;
}
else if(ch >= 'A' && ch <=
'Z'){ch = ch + key;
if(ch > 'Z'){
ch = ch - 'Z' + 'A' - 1;
}
str_message[j] = ch;
}
}
printf("Encrypted message: %s", str_message);
getch();
return 0;
}
Output:
Page No : 3
By Prof.R.H.Rathod, Comp.Engg. Deptt., Dr.Panjabrao Deshmukh Polytechnic, Amravati
Network and Information Security (22620)
Program For
Decryption:
#include<stdio.h>
int main()
{
char str_message[500],
ch;int j, key;
printf("Enter a message to decrypt: ");
scanf("%s",str_message);
printf("Enter key: ");
scanf("%d", &key);
for(j = 0; str_message[j] != '\0';
++j){ch = str_message[j];
if(ch >= 'a' && ch <= 'z')
{
ch = ch -
key;if(ch <
'a'){
ch = ch + 'z' - 'a' + 1;
}
str_message[j] = ch;
}
else if(ch >= 'A' && ch <=
'Z'){ch = ch - key;
if(ch < 'A')
{
ch = ch + 'Z' - 'A' + 1;
}
str_message[j] = ch;
}
}
printf("Decrypted message: %s", str_message);
getch();
return 0;
Page No : 4
By Prof.R.H.Rathod, Comp.Engg. Deptt., Dr.Panjabrao Deshmukh Polytechnic, Amravati
Network and Information Security (22620)
}
Output:
XII. Observations
Create encryption key and decryption key for given message.
XIII. Questions
Q1. What is Caesar Cipher technique?
….…………………………………………………………………………………………….
.……………………………………………………………………………………………….
….…………………………………………………………………………………………….
.……………………………………………………………………………………………….
….…………………………………………………………………………………………….
.……………………………………………………………………………………………….
4) …………………………………….
Signature of Teacher
Page No : 5
By Prof.R.H.Rathod, Comp.Engg. Deptt., Dr.Panjabrao Deshmukh Polytechnic, Amravati