Hi all. I just recently found an old encryption program I gave up on back in highschool on an old jump drive. I was wanting to teach myself about typecasting, file I/O, and a little encryption all in the same project. I actually wrote two programs. The first takes in a phrase one letter at a time and converts them to numbers through typecasting. Next, It adds whatever number is in the file "numerical.txt" and writes the resulting number to a file called "example.txt". Whenever it comes time to undo what has been done, the second program simply reverses the process by reading from the two files and subtracting. Problem is, instead of perfectly legible letters, I simply get the symbol for null (I believe that's what it is). When I open up example.txt, the numbers are huge. (In the hundreds of thousands, instead of the standard ascii), so I'm assuming the problem is in the encryption algorithm. I'd love to finally be able to get this program to work. Anyway, here's the code:
Encryptor:
Code:
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <windows.h>
#include <process.h>
using namespace std;
int main()
{
cout<<"Personal encryptor, v 0.2\n";
cout<<"Andrew Hodge. June 10, 2011. \n \n \n" << endl;
int str;
int alexandria;
char input;
int oxnhill;
int laurel;
oxnhill = 1;
washington:
ifstream c_file("numerical.txt");
c_file>>laurel;
c_file.close();
while (oxnhill< 0){
ofstream a_file ("example.txt", ios::app);
a_file<< "Unit line______Score_________\n";
a_file.close();
//oxnhill++;
goto washington;
}
cin>>input;
if (input==99){
goto arnold_sw;
}
else{
alexandria=(int)input ;
ofstream a_file ( "example.txt", ios::app );
a_file<<alexandria + laurel;
a_file<<"\n"
a_file.close();
goto washington;
}
arnold_sw:
return 0;
}
Decryptor:
Code:
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <windows.h>
#include <process.h>
using namespace std;
int main(){
int alexandria;
int laurel;
int baltimore;
int patomic;
ifstream a_file ("numerical.txt");
a_file>>laurel;
a_file.close();
ifstream b_file ("example.txt");
b_file>>alexandria;
b_file.close();
baltimore= alexandria-laurel ;
patomic= baltimore;
cout<< (char) patomic ;
}