Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  encoder
Language: C/C++
Code:
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<stdlib.h>


int j,k;

char str1[]="abcdefghijklmnopqrstuvwxyz$!&_*+-1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char str2[]="$!&_*[email protected]A";
     void enc(char str[])
{
for(int i=0;str[i]!='\0';i++)
{
while(str1[j]!=str[i])
j++;
str[i]=str2[j];
j=0;
}
}
void dec(char str[])
{ for(int i=0;str[i]!='\0';i++)
 {while(str2[j]!=str[i])
 j++;
 str[i]=str1[j];
 j=0;


}
}
void encrypt()
{ clrscr();
cout<<"WELCOME To THE Encrypter"<<endl;
cout<<"This Program will encrypt the data of IN.TXT\nand write it in ENC.TXT";
cout<<endl<<"Press any Key To proceed";
getch();
ifstream in;ofstream out;
char line[80];
in.open("IN.TXT");out.open("ENC.TXT");
while(!in.eof()){
in.getline(line,80,'\n');
enc(line);
out<<line;
 }
in.close();
out.close();
cout<<"\nDONE";
getche();

     }




     void decrypt()
{clrscr();
cout<<"WELCOME To the Decrypter"<<endl;
cout<<"This Program will Decrypt the data of ENC.TXT and write it to DEC.TXT"<<endl;
cout<<"Press any key to proceed"<<endl;
getch();
ifstream in;ofstream out;
char line[80];
in.open("ENC.TXT");out.open("DEC.TXT");
while(!in.eof()){
in.getline(line,80,'\n');
dec(line);
out<<line<<endl;
}

in.close();
out.close();
cout<<"DONE";
getche();

     }



void main(){
clrscr();
char str[50];
cout<<"\t\tWElcome to Encrypter"<<endl;
cout<<"What do you want to do"<<endl;
cout<<"1.Encrypt the file IN.TXT\n2.Decrypt the file ENC.TXT\n3.Exit"<<endl;
cout<<"Enter the response";
char response=getche();
switch(response)
{ case '1': encrypt();
     break;
  case '2':    decrypt();
  case '3': exit(0);
}
getche();


      }
     
Comments: