CO 405 Information and Network Security Practical File: Delhi Technological University

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

CO 405

Information and Network Security


Practical File

Delhi Technological University

Name: Avneesh Saraswat


Roll No: 2K17/CO/084
Practical 2
Aim: To implement Monoalphabetic decryption.
Introduction: Encrypting and Decrypting works exactly the same for all monoalphabetic
ciphers. Encryption/Decryption: Every letter in the alphabet is represented by exactly one
other letter in the key.
A monoalphabetic cipher is any cipher in which the letters of the plain text are mapped to
cipher text letters based on a single alphabetic key. Examples of monoalphabetic ciphers
would include the Caesar-shift cipher, where each letter is shifted based on a numeric key,
and the atbash cipher, where each letter is mapped to the letter symmetric to it about the
center of the alphabet.
Implementation:
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char pt[52]={'A','B','C','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','d','e','f','g','h',
'i','j','k','l','m','n','o','p','q','r','s','t',
'u','v','w','x','y','z'};
char ct[52]={'Z','Y','X','W','V','U','T','S','R','Q','P','O',
'N','M','L','K','J','I','H','G','F','E','D','C',
'B','A','z','y','x','w','v','u','t','s','r','q','p','o',
'n','m','l','k','j','i','h','g','f','e','d','c','b','a'};
char p[20]={'\0'},c[20]={'\0'},r[20]={'\0'};
int i,j;
printf("\n enter the plain text:");
gets(p);
for(i=0;i<strlen(p);i++)
{
for(j=0;j<52;j++)
{
if(pt[j]==p[i])
{
c[i]=ct[j];
}
}
}
printf("\n cipher text is: %s",c);
for(i=0;i<strlen(c);i++)
{
for(j=0;j<52;j++)
{
if(ct[j]==c[i])
{
r[i]=pt[j];
}
}
}
printf("\n \n plain text is: %s",r);
}
Output:

Conclusion and Learning:


Thus we have finally learnt how to successfully implement Monoalphabetic Decryption.

You might also like