Encryption and Decryption using a c program

encryption is process through which we can change a text into a coded language  with this method we can hide data for unwanted users and  used for security purpose. in networking our data transfer from one end to another using this encryption and decryption .decryption means to decode the previously coded message.
here in this program we are just adding a integer 2 value in each character of the given message and for decoding we are just subtracting 2 from the previously coded message.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[50];
int i,x;
       do{

printf("press 1.Encryption \n 2.Decryption\n3.exit\n");
scanf("%d",&x);

clrscr();

       switch(x)
       {

case 1:


puts("Enter your message\n");
gets(str);
  printf("encrypted message is here:\n");
for(i=0;str[i]!='\0';i++)
{
      str[i]=str[i]+2 ;
     printf("%c",str[i]);
}
printf("\n");

break;
case 2:
printf("Dencrypted message is here:\n");
for(i=0;str[i]!='\0';i++)
{
      str[i]=str[i]-2 ;
     printf("%c",str[i]);

}
printf("press any key to continue");
getch();

printf("\n");
break;


}

}while(x!=3);


}

Comments

Popular posts from this blog

Pre-compiled Headers

CONNECTING WITH FTP-FILE TRANSFER PROTOCOL

PROBING THE INTERNET WITH TELNET: