#include #include #include #include #include "utile.h" void PrintTitle(); char PrintMenu(); void MenuCmd(char); void kill(); void Mop1(); void Mop2(); void Mop3(); void Mop4(); void Mop5(); void Mop6(); void Mop6(); void Mop7(); void Mop9(); int op1; int op2; int op3; int op4; int op5; int op6; int op7; int op9; int main() { PrintTitle(); //should be do loop char enter; do { enter = PrintMenu(); MenuCmd(enter); } while(enter != '8'); kill(); return 0; } char PrintMenu() { char c; cout <> c; return c; } void MenuCmd(char x) { switch(x) { case '1': Mop1(); break; case '2': Mop2(); break; case '3': Mop3(); break; case '4': Mop4(); break; case '5': Mop5(); break; case '6': Mop6(); break; case '7': Mop7(); break; case '9': Mop9(); break; } } // menu command option function bodys // Period Scan void Mop1() { op1++; char filename[100]; cout << "\n Enter Filename: "; cin >> filename; char code[5000]; ifstream fin(filename); if(fin.fail()) { cout << "Error: Failure file not found or damaged! "; return; } char ch; int index = 0; while(fin.get(ch)) { code[index] = ch; index++; } code[index] = 0; fin.close(); cout << "\n\n" << code; cout << "\n"; int pcount = 0;// period count int space_index[100]; int scount = 0;// for words use a space count (check data chunks with 1 space before 1 space after) int len; len = strlen(code); for(int i = 0; i < len; i++) { if(code[i] == '.') { pcount++; } if(code[i] == ' ') { space_index[scount] = i; scount++; } } cout << "\n (" << pcount << ") Periods within String"; } void Mop2() { op2++; char filename[100]; char nfilename[100]; cout << "\n Enter Filename: "; cin >> filename; cout << "\n Enter new FileName: "; cin >> nfilename; char code[5000]; ifstream fin(filename); if(fin.fail()) { cout << " Error: Failure file not found or damaged! "; return; } char ch; int index = 0; while(fin.get(ch)) { code[index] = tolower(ch); index++; } fin.close(); code[index] = 0; // now rewriting the code buffer as lowercase form to file ofstream fout(nfilename); fout << code; fout.close(); cout << "\n- Succesfuly written in lowercased form to : " << nfilename; } void Mop3() { op3++; char filename[100]; char nfilename[100]; cout << "\n Enter Filename: "; cin >> filename; cout << "\n Enter new FileName: "; cin >> nfilename; char code[5000]; ifstream fin(filename); if(fin.fail()) { cout << " Error: Failure file not found or damaged! "; return; } char ch; int index = 0; while(fin.get(ch)) { code[index] = toupper(ch); index++; } fin.close(); code[index] = 0; // now rewriting the code buffer as lowercase form to file ofstream fout(nfilename); fout << code; fout.close(); cout << "\n- Succesfuly written in uppercased form to : " << nfilename; } // Encrypt void Mop4() { char filename[100]; cout << "\n* Enter Filename: "; cin >> filename; char code[5000]; ifstream fin(filename); if(fin.fail()) { cout << " Error: Failure file not found or damaged! "; return; } char ch; int index = 0; while(fin.get(ch)) { code[index] = toupper(ch); index++; } fin.close(); code[index] = 0; char pw[25]; char buff[500]; char newbuff[500]; strcpy(buff,code); cout << "\n Enter Password For Encryption: "; cin >> pw; op4++; if(strlen(pw) < 3) { cout << "\n Password to Short Error"; return; } // ERR int layera_1; int layera_2; int layera_3; int e_switch = 0; layera_1 = pw[1] + 3; layera_2 = pw[2] - 3; layera_3 = pw[3] + strlen(pw); char layer1buff[9000]; int len = strlen(buff); for(int x = 0; x < len; x++) { int add; add = buff[x]; switch(e_switch) { case 0: layer1buff[x] = add + layera_1; break; case 1: layer1buff[x] = add + layera_2; break; case 2: layer1buff[x] = add + layera_3; break; } e_switch++; if(e_switch >= 3) { e_switch = 0; } } layer1buff[len] = 0; strcpy(newbuff, layer1buff); strcat(newbuff, "ÉeE%#(*)"); // writing to file ofstream fout(filename); fout << newbuff; fout.close(); cout << "\n" << filename << " now encrypted "; } // Decrypt void Mop5() { op5++; char filename[100]; cout << "\n Enter Filename: "; cin >> filename; char code[5000]; ifstream fin(filename); if(fin.fail()) { cout << " Error: Failure file not found or damaged! "; return; } char ch; int index = 0; while(fin.get(ch)) { code[index] = toupper(ch); index++; } fin.close(); code[index] = 0; char pw[25]; char buff[500]; char newbuff[500]; strcpy(buff,code); cout << "\n Enter Password For Decryption"; cout<<"(if you mess up file will be destored for saftey purposes): "; cin >> pw; if(strlen(pw) < 3) { cout << "\nERROR: pw to short"; return; } // ERR int layera_1; int layera_2; int layera_3; int e_switch = 0; layera_1 = pw[1] + 3; layera_2 = pw[2] - 3; layera_3 = pw[3] + strlen(pw); char layer1buff[9000]; int len = strlen(buff); for(int x = 0; x < len; x++) { int add; add = buff[x]; switch(e_switch) { case 0: layer1buff[x] = add - layera_1; break; case 1: layer1buff[x] = add - layera_2; break; case 2: layer1buff[x] = add - layera_3; break; } e_switch++; if(e_switch >= 3) { e_switch = 0; } } layer1buff[len] = 0; strcpy(newbuff, layer1buff); newbuff[len-8] = 0; newbuff[len-9] = 0; // writing to file ofstream fout(filename); fout << newbuff; fout.close(); cout << "\n" << filename << " now decrypted "; } void Mop6() { op6++; char filename[100]; cout << "\n Enter Filename: "; cin >> filename; cout << " Enter File body: "; char stringone[255]; cin >> stringone; ofstream fout(filename); fout << stringone; fout.close(); cout << "\n Text file succesfuly created."; } void Mop7() { op7++; char filename[100]; cout << "\n Enter Filename: "; cin >> filename; char code[5000]; ifstream fin(filename); if(fin.fail()) { cout << " Error: Failure file not found or damaged! "; return; } char ch; int index = 0; while(fin.get(ch)) { code[index] = ch; index++; } code[index] = 0; fin.close(); cout << "\n\n" << code; cout << "\n"; } // op8 void kill() { int x; cout << "\n*Option 8*\n"; cout << "***Invoke count***\n"; cout << "\n Option1 : " << op1; cout << "\n Option2 : " << op2; cout << "\n Option3 : " << op3; cout << "\n Option4 : " << op4; cout << "\n Option5 : " << op5; cout << "\n Option6 : " << op6; cout << "\n Option7 : " << op7; cout << "\n Option9 : " << op9; cout <> x; } void Mop9() { op9++; cout << "\n***Option 9 Mad Libs****\n"; char n1[100]; char n2[100]; char n3[100]; char n4[100]; char free1[100]; char free2[100]; char free3[100]; char free4[100]; cout << "\nEnter a Noun: "; cin >> n1; cout << "\nEnter a Noun: "; cin >> n2; cout << "\nEnter a Noun: "; cin >> n3; cout << "\nEnter a Noun: "; cin >> n4; cout << "\nFree style off the top of your head\n"; cout << "\nF1: " ; cin >> free1; cout << "\nF2: " ; cin >> free2; cout << "\nF3: " ; cin >> free3; cout << "\nF4: " ; cin >> free4; cout << "\nThe result of your Mad work\n"; cout << " As the master went outside today, fell across a blue " << n1; cout << "\nA single star, appear way out in the sky, replayed the vision"; cout << "\n of the " << n2; cout << " remembering the intense stream of life \n"; cout << "\nreturning the results of what is right"; cout << "\ntry to poke your eyes in my space use the " << n3; cout << "\ntry to make me write it all over the place "; cout << "\ntry to foce me like how you think should " << n4; cout << "\nremember its just your lies, and we always knew I would\n"; cout << "\n\nFreestyle thoughts now flow to you, whats in your mind"; cout << "\nIs now appeared to you\n"; cout << "\nflowing green: " << free1; cout << "\nstream of thought: " << free2; cout << "\niam the king: " << free3; cout << "\nDoctor of love: " << free4; cout << " - \n - the end -"; }