#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
char cipher[50], plain[50], key[50];
int ch, i, lp, lk;
clrscr();
while(1)
{
printf("\n Menu\n\n1.DataEncryption\n2Decryption\n3.Exit\n\n Enter u r choice:");
scanf("%d", &ch);
switch(ch)
{
case 1: printf("\n Data Encryption");
printf("\n Enter the plain text:");
fflush(stdin);
gets(plain);
printf("\n Enter Encryption Key: ");
gets(key);
lp=strlen(plain);
lk=strlen(key);
while(lp!=lk)
{
printf("\n Invalid Encryptio");
printf("\n Enter the Encryption key: ");
gets(key);
lk=strlen(key);
}
for(i=0;plain[i]!='\0';i++)
cipher[i]=plain[i]^key[i];
printf("\n Encrypted text is: ");
cipher[i]='\0';
puts(cipher);
break;
case 2: printf("\n Decryption");
for(i=0;cipher[i]!='\0';i++)
plain[i]=cipher[i]^key[i];
printf("\n The Decrypted text is: ");
puts(plain);
break;
case 3: exit(0);
default: printf("\n Invalid option");
}
}
// getch();
}
output:
Menu
1.DataEncryption
2Decryption
3.Exit
Enter u r choice:1
Data Encryption
Enter the plain text:ramudayina
Enter Encryption Key: 25869745613 or may be jntuhyderabad like text also
Encrypted text is: QP[?Z_]GW]R
Menu
1.DataEncryption
2Decryption
3.Exit
Enter u r choice:2
Decryption
The Decrypted text : ramudayina
Menu
1.DataEncryption
2Decryption
3.Exit
Enter u r choice:3
exit
#include<conio.h>
#include<stdlib.h>
void main()
{
char cipher[50], plain[50], key[50];
int ch, i, lp, lk;
clrscr();
while(1)
{
printf("\n Menu\n\n1.DataEncryption\n2Decryption\n3.Exit\n\n Enter u r choice:");
scanf("%d", &ch);
switch(ch)
{
case 1: printf("\n Data Encryption");
printf("\n Enter the plain text:");
fflush(stdin);
gets(plain);
printf("\n Enter Encryption Key: ");
gets(key);
lp=strlen(plain);
lk=strlen(key);
while(lp!=lk)
{
printf("\n Invalid Encryptio");
printf("\n Enter the Encryption key: ");
gets(key);
lk=strlen(key);
}
for(i=0;plain[i]!='\0';i++)
cipher[i]=plain[i]^key[i];
printf("\n Encrypted text is: ");
cipher[i]='\0';
puts(cipher);
break;
case 2: printf("\n Decryption");
for(i=0;cipher[i]!='\0';i++)
plain[i]=cipher[i]^key[i];
printf("\n The Decrypted text is: ");
puts(plain);
break;
case 3: exit(0);
default: printf("\n Invalid option");
}
}
// getch();
}
output:
Menu
1.DataEncryption
2Decryption
3.Exit
Enter u r choice:1
Data Encryption
Enter the plain text:ramudayina
Enter Encryption Key: 25869745613 or may be jntuhyderabad like text also
Encrypted text is: QP[?Z_]GW]R
Menu
1.DataEncryption
2Decryption
3.Exit
Enter u r choice:2
Decryption
The Decrypted text : ramudayina
Menu
1.DataEncryption
2Decryption
3.Exit
Enter u r choice:3
exit
కామెంట్లు లేవు:
కామెంట్ను పోస్ట్ చేయండి