*Bump*
I'd really like some help on this issue... my current Encryption program looks like this:
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main (char*)
{
ifstream Fileop;
ofstream DestFil;
char Filenam[32];
char OutFile[32];
unsigned char ich;
unsigned char och;
int asc;
bool firstrun = true;
long begin,end;
cout << "Encryptor\n-----------\nCreated by:Rider Rockon"; // A little bit of interface
cout << "\n\n\nFile to Encrypt:> ";
cin >> Filenam; // Wait for input, make Filenam whatever was typed
cout << "Destination File:> ";
cin >> OutFile; // Wait for input, make OutFile whatever was typed
cout << "\n Opening Input: " << Filenam << " and Output: " << OutFile << "\n";
Fileop.open (Filenam);
DestFil.open(OutFile,ios::trunc);
// Count File size & Return the cursor to the start of the file
begin = Fileop.tellg();
Fileop.seekg (0, ios::end);
end = Fileop.tellg();
Fileop.seekg (0, ios::beg);
cout << "Encrypting " << (end-begin) << " bytes of Data...\n";
while (Fileop.good()) // As long as there's no Error or End of File
{
if ( firstrun == false ) { DestFil.write(reinterpret_cast < char * > (&och), sizeof(och)); };
Fileop.read(reinterpret_cast < char * > (&ich), sizeof(ich));
asc = (int)ich;
// Encrypt ASC here preparing it for output
asc = asc + 1;
och = (unsigned char)asc;
if ( firstrun == true ) { firstrun = false; };
};
cout << "\nDone...\n";
Fileop.close();
DestFil.close();
return 0;
}
as stated above, the file being encrypted is reduced in size greatly (My 413KB file became 3.50KB) and I can't quite figure out where I'm messing up.
Could anyone please help me out? I'm just a beginning programmer and I haven't got too much experience so far... heck... I'm suprised I even got this far!
Any help on the matter would be greatly appreciated