INTRODUCTION:
Symmetric Key encryption technique uses only one key to encrypt/decrypt a message. This program is implemented in C++ .
PROGRAM:
Symmetric Key encryption technique uses only one key to encrypt/decrypt a message. This program is implemented in C++ .
PROGRAM:
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int key1,key2;
char s,wish;
int choice;
printf("\nExpt No.3 \tSYMMETRIC ENCRYPTION AND DECRYPTION\t18/02/2013");
do {
cout<<"\n1:Sender side\n2:Receiver side\n3:exit(0)";
cout<<"\nEnter your choice:";
cin>>choice;
printf("\nAt Sender side:");
printf("\nEnter the key:");
scanf("%d",&key1);
printf("\nAt Receiver side:");
printf("\nEnter the key:");
scanf("%d",&key2);
printf("\nEnter the message:");
s=getchar();
if(key1==key2)
{
printf("\nKeys Match..you can proceed communication");
}
else
{
printf("\nKeys do not match...connection lost.....");
exit(0);
}
switch(choice)
{
case 1:
// printf("\nEncrypted text is: ");
while(s!='\n')
{
if(s==' ')
putchar(s);
else
{
putchar(s+key1);
}
s=getchar();
}
putchar(s);
break;
case 2:
while(s!='\n')
{
if(s==' ')
putchar(s);
else{
putchar(s-key2);
}
s=getchar();
}
putchar(s);
break;
default:
exit(0);
}
printf("\nDo you want to continue communnication:?(y or Y)");
scanf("%c",&wish);
} while(wish=='y'||wish=='Y');
return 0;
}
OUTPUT:
Expt No.3 SYMMETRIC ENCRYPTION AND DECRYPTION 18/02/2013
1:Sender side
2:Receiver side
3:exit(0)
Enter your choice:1
At Sender side:
Enter the key:4
At Receiver side:
Enter the key:4 symmetric
Enter the message:
Keys Match..you can proceed communication w}qqixvmg
Do you want to continue communnication:?(y or Y)y
1:Sender side
2:Receiver side
3:exit(0)
Enter your choice:2
At Sender side:
Enter the key:4
At Receiver side:
Enter the key:4 w}qqixvmg
Enter the message:
Keys Match..you can proceed communication symmetric
Do you want to continue communnication:?(y or Y)n
0 comments:
Post a Comment
If You Are Asking Some Question On This Comment Then Click On Subscribe by email Link