All pastes #783517 Raw Edit

Something

public cpp v1 · immutable
·published 2007-11-19 07:01 UTC
rendered paste body
void cypher(int dir){	// custom character set	char salt[] = "0123456789abcdefghijklmnopqrstuvwxyz";	char fn[20], buffer;	int ch, seed;	// get filename	cin.ignore(80, '\n');	cout << "Enter filename: ";	cin.get(fn, 20);	cin.ignore(80, '\n');	// open files	ifstream ifile;	ifile.open(fn, ios::in);	ifile.unsetf(ios::skipws);	ofstream ofile;	ofile.open("temp", ios::out);	// call to function get_seed	seed = get_seed();	ifile >> buffer;	while(!ifile.eof()){		ch = int(buffer);		if(isalnum(buffer)){			// get rid of caps			if(ch >= 65 && ch <= 90)				ch = int(buffer) + 32;			// reset numbers to below alphabet in ascii			else if(ch >= 48 && ch <= 57)				ch = int(buffer) + 39;						// subtract 87 to make int('0') = 0			ch = ch - 87;						// add 18 (rot18) and the seed, depending on direction			ch = ch + 18 + (seed * dir);						// make sure ch is within bounds (0 and 35)			ch = ch % 36;						seed++;			ofile << salt[ch];		}		else{			ofile << buffer;		}		ifile >> buffer;	}	ifile.close();	ofile.close();		// copy file, clear temp	copy_file("temp", fn);	ofile.open("temp", ios::out);	ofile.close();}