I tried making a simple file encrypter....
what it does it open a file, get 1 char by char. take that char and add the "key" to it..
So char "A" which is 65 added to (lets say key is 1) 1 is 66 which is "B"
the dycrpted would decrypt this but i cant compile it. And please check for errors or any suggestions, and if this program will work
These are teh compile errors under cl.exe
Code:
xcrypt.cpp
xcrypt.cpp(37) : error C2362: initialization of 'make' is skipped by 'goto end'
xcrypt.cpp(27) : see declaration of 'make'
xcrypt.cpp(37) : error C2362: initialization of 'make' is skipped by 'goto end'
xcrypt.cpp(27) : see declaration of 'make'
xcrypt.cpp(37) : error C2362: initialization of 'read' is skipped by 'goto end'
xcrypt.cpp(19) : see declaration of 'read'
the code:
Code:
#include<iostream.h>
#include<fstream.h>
int main()
{
char Filename[50], chr;
int Key;
cout<<"Enter Filename To Encrypt";
cin>>Filename;
cout<<"Enter Key # (1-10)";
cin>>Key;
if(Key>10){ // Checks if key is no greater then 10
cout<<"Invalid Key";
goto end;
}
ifstream read;
read.open(Filename,ios::in);
if(!read){ // Checks if file exists
cout<<"Unable To Open File";
goto end;
}
ofstream make; // Creats file "Encrypted.tmp"
make.open("Encrypted.tmp",ios::out);
while(read)
{
read.get(chr); // Gets chr
chr = chr + Key; // Takes the char and adds to it 'Key'
make<<chr; // Writes Encrypted chr
}
end:
return 0;
}