You are on page 1of 5

Caesar Cipher 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 shift of 3, D would be
replaced by A, E would become B, and so on

i) Caesar cipher

The Caesar cipher involves replacing each letter of the alphabet with the letter
standing three places further down the alphabet.

For example

a bcdefgh ij k l m n o p q r s t u v w x y z

0 1 2 3 4 5 6 7 8 9 10 11 12 3 14 15 16 17 18 19 20 21 22 23 24 25

Plain Text: a bc d e f gh i j k l m n o p q r s t u v w x y z

Cipher Text: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

Encryption

C=P+SK

Shift Key : 3

C= E(3,p)=(p+3) mod 26

A Shift may be of any amount, so that the general Caesar algorithm is

C=E(k,p)=(p+k)mod 26

Where k takes on a value in the range 1 to 25. The decryption algorithm is simply

p=D(k,C)=(C-k)mod 26
ii) Playfair Cipher

Key word: MONARCHY (5 * 5)

M O N A R

C H Y B D

E F G I/J K

L P Q S T

U V W X Z

BALLOON

BA LX LO ON

I/JB SU MP NA

IB/JB

https://www.geeksforgeeks.org/playfair-cipher-with-examples/
iii) Vigenere Cipher

Plain Text : BE ACTIVE

Key :MAN
Encryption Program for Caesar Cipher

#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<iostream>
using namespace std;
int main() {
char array[100]={0}, cipher[100]={0};
cout<< "Enter the string to be encrypted"<<endl;
int c;
while((c=getchar()) != '\n') {
static int x=0, i=0;
array[i++]=(char)c;
cipher[x++]=(char)(c+3);
}
cout<<" Ciphertext of Message will be\t"<<cipher<<endl;
getch();
return 0;
}
Decryption program for Caesar Cipher

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main() {
char array[100]={0}, cipher[100]={0};
cout<< "Enter the string to be decrypted"<<endl;
int c;
while((c=getchar()) != '\n') {
static int x=0, i=0;
array[i++]=(char)c;
cipher[x++]=(char)(c-3);
}
cout<<" Decrypted Message will be\t"<<cipher<<endl;
getch();
return 0;
}

You might also like