Cryptography Techniques: Project Report ON
Cryptography Techniques: Project Report ON
Cryptography Techniques: Project Report ON
ON
CRYPTOGRAPHY TECHNIQUES
1. CERTIFICATE
2. ACKNOWLEDGEMENT
3. INTRODUCTION
4. CODE
6. BIBLIOGRAPHY
DHARAMSINH DESAI UNIVERSITY
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
Certificate
This is to certify that the term project work carried out on topic
CRYPTOGRAPHY TECHNIQUES and recorded in this report is bonafied
work of Mr.PATEL PRATIK D (ME-10) of M.TECH semester 1st in the
branch of ELECTRONICS & COMMUNICATION during the academic year
2010-11.
Date: Date:
ACKNOWLEDGEMENT
With deep sense of gratitude, first and foremost I express my profound thanks to my project
incharge MR.M.J.LIMACHIYA for giving me opportunity to carry out term project on my
chosen topic & giving me continuous support and help throughout the project.
I would also like to thanks to my friends for their help and support while preparing this project.
I would also like to thank all those who directly or indirectly made my project a great
learning experience.
Introduction
Cryptography: The science of the enciphering and deciphering of messages in secret code or
cipher.
Encryption is a method of transforming original data, called plaintext or cleartext, into a form
that appears to be random and unreadable, which is called ciphertext. Plaintext is either in a form
that can be understood by a person (a document) or by a computer (executable code). Once it is
not transformed into ciphertext, human nor can machine properly process it until it is decrypted.
This enables the transmission of confidential information over insecure channels without
unauthorized disclosure. When data is stored on a computer, it is usually protected by logical and
physical access controls. When this same sensitive information is sent over a network, it can no
longer take these controls for granted, and the information is in a much more vulnerable state.
A system that provides encryption and decryption is referred to as a cryptosystem and can be
created through hardware components or program code in an application. The cryptosystem uses
an encryption algorithm, which determines how simple or complex the process will be. Most
algorithms are complex mathematical formulas that are applied in a specific sequence to the
plaintext. Most encryption methods use a secret value called a key (usually a long string of bits),
which works with the algorithm to encrypt and decrypt the text.
Ceaser Cipher.
Ceaser Cipher:
In the Caesar Cipher, each letter is replaced with the letter three places beyond it in the alphabet.
This is referred to as a shift alphabet. If the Caesar Cipher is used with the English alphabet,
when George wants to encrypt a message of “FBI,” the encrypted message would be “IEL.”
Define Shift
Enter
Message
Convert
message to
ASCCI
Add Shift to
Message
Monoalphabetic Cipher:
HELLOABCDEFGIJK...............MNPQ………UXYZ
Vigenere Cipher:
-Implementation of Vigenere cipher:
Vigenere cipher is a polyalphabetic substitution cipher which is an extension of Mono alphabetic
cipher. In this case we have more than one substitution sequences out of which we have to select
only one sequence to encrypt the plain text. The selection is based on Key value, so for the same
message and different key the encryption will be different.
In this particular algorithm we have 26 different sequences which are describe as follow
1) A B C D …………………X Y Z
2) B C D E…………………..Y Z A
3) C D E F…………………Y Z A B
So on…….up to
26) Z A B C………………X Y
This sequences are arrange in a tabular form (26X26) as shown below
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
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
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
Here, each row corresponds to the message character (i.e. first raw corresponds to Message
character A)and each column corresponds to Key character (i.e. first column corresponds to Key
character A)
Step to Encrypt the Message:
1) Accept the key and Message and expand the key by repeating it over and over so that
its length becomes equal to message length and then
2) Take the pair of key character and corresponding message character at a time
- Find the row corresponding to message character
- Find the column corresponding to key character
3) Replace the message character with the character occupied by the row and column
obtain from step2
4) Repeat the process until end of message.
Implementation in C:
For implementing above techniques in C. I have made combined program for all the above
mentioned techniques using Switch and Case Statements.
Program code
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<graphics.h>
#include<iostream.h>
#define s 4
void main()
{
int gdriver=DETECT,gmode;
// ceaser cipher technique variables declaration
char az[50];
int ii,n=0,l=0,ch,chi;
//mono technique variables declaration
char key[25];
char pt[100];
char ct[100];
char dpt[100];
char a[26];
char b[26];
int keylen,plen=0,k=0,i,j=0,flag;
//vigenere variables declaration
char msg[100];
char atoz[26][26]={0};
char enc[100];
char dec[100];
char key1[50],temp1[50];
int i1,j1,l1,ch1,k1,x1,y1,len1;
clrscr();
initgraph(&gdriver,&gmode,"d:\\tc\\bgi");
setcolor(YELLOW);
settextstyle(10,0,0);
setusercharsize(30,20,35,40);
outtextxy(10,30," CRYPTOGRAPHY");
switch(ch)
{
case 1:
initgraph(&gdriver,&gmode,"d:\\tc\\bgi");
setcolor(20);
settextstyle(1,0,0);
setusercharsize(20,10,30,40);
outtextxy(90,30,"CEASER CIPHER");
cout<<"\n\n\n\n\n\n Enter your String:";
cin>>az;
printf(" \n Enter your Choice:- \n");
printf("\n 1.Encryption.\n 2.Decryption.");
printf("\n");
cin>>chi;
ii=0;
while(az[ii]!='\0')
{
l++;
ii++;
}
if(ch==1)
{
for(ii=0;ii<l;ii++)
{
n=az[ii];
if(n>=65&&n<=90)
{
if(n>=(90-s))
{
n=64-(90-n);
}
}
if(n>=97&&n<=122)
{
if(n>=(122-s))
{
n=96-(122-n);
}
}
n=n+s;
printf("%c",n);
}
}
else
{
for(ii=0;ii<l;ii++)
{
n=az[ii];
if(n>=65&&n<90)
{
if(n<=(64+s))
{
n=90+(n-64);
}
}
if(n>=97&&n<=122)
{
if(n<=(96+s))
{
n=122+(n-96);
}
}
n=n-s;
printf("%c",n);
}
}
getch();
break;
case 2:
flag=0;
for(j=i;j>0;j--)
if(b[j]==a[k])
flag=1;
if(flag==0)
b[i++]=a[k];
//cout<<b[k]<<" ";
}
//cout<<"\n\n";
cout<<"Enter message: ";
cin>>pt;
plen=strlen(pt); // length of plain text
cout<<"\n\n";
cout<<"cipher text: ";
for(i=0;i<plen;i++) // encryption part
{
if(pt[i]==' ')
ct[i]=pt[i];
else
for(j=0;j<26;j++)
if(pt[i]==a[j])
ct[i]=b[j];
cout<<ct[i];
}
case 3:
initgraph(&gdriver,&gmode,"d:\\tc\\bgi");
setcolor(10);
settextstyle(1,0,0);
setusercharsize(20,10,20,40);
outtextxy(60,30,"VIGENERE CIPHER");
for (i1=0,k1=97;i1<26;i1++,k1++)
{
if(k1>122)
{
k1=97;
}
l1=k1;
for(j1=0;j1<26;j1++){
if(l1>122)
{
l1=97;
}
atoz[i1][j1]=l1++;
// cout<<atoz[i1][j1];
}
// printf("\n");
}
printf("\n\n\n\n\n\n Enter Key : ");
cin>>key1;
len1=strlen(msg);
// printf("%d",len1);
strcpy(temp1,key1);
//printf("%s",temp1);
while(strlen(temp1)<len1)
strcat(temp1,key1);
strcpy(key1,temp1);
//printf("%s",key1);
key1[len1]=NULL;
cout<<"\n";
cout<<"\n Encrypted text is:";
for(i1=0;i1<len1;i1++)
{
x1=key1[i1]-97;
y1=msg[i1]-97;
enc[i1]=atoz[x1][y1];
printf("%c",enc[i1]);
}
}
printf("%c",dec[i1]);
}
getch();
Break;
} }
BIBLIOGRAPHY