/************************************ * TextCrypt * * By: Rollin92 * * http://www.warpdworld.com * * Simple text file encryption * * and decryption. Not complex * * at all, but may help someone. * *************************************/ #include #include #include int menu(); int main() { int choice = 0; char* filename; char* filename2; char buffer[255]; int i = 0; int temp = 0; cout << "TextCryptor"; do { choice = menu(); cin.ignore(); if(choice == 1) { cout << endl << endl << "Enter file path: "; cin.getline(buffer,sizeof(buffer)); filename = new char[strlen(buffer) + 1]; strcpy(filename,buffer); fstream in_file(filename, ios::in); if(!in_file) { cout << endl << "Error opening file, make sure the path is correct" << endl; continue; } cout << endl << "Enter path for encrypted file: "; cin.getline(buffer,sizeof(buffer)); filename2 = new char[strlen(buffer) + 1]; strcpy(filename2,buffer); fstream out_file(filename2, ios::out); while(true) { in_file.getline(buffer,sizeof(buffer)); for(i = 0; i < (strlen(buffer)); i++) { out_file << (buffer[i] + 3) << "\n"; } if(in_file.eof()) { break; } } in_file.close(); out_file.close(); cout << endl << endl << "Encryption Complete" << endl; } if(choice == 2) { cout << endl << endl << "Enter file path: "; cin.getline(buffer, sizeof(buffer)); filename = new char[strlen(buffer) + 1]; strcpy(filename,buffer); fstream in_file(filename, ios::in); if(!in_file) { cout << endl << endl << "Error opening file!"; continue; } cout << endl << endl << "Enter path for unencrypted file: "; cin.getline(buffer, sizeof(buffer)); filename2 = new char[strlen(buffer) + 1]; strcpy(filename2, buffer); fstream out_file(filename2, ios::out); while(true) { in_file >> temp; if(in_file.eof()) { break; } out_file << static_cast(temp - 3); } in_file.close(); out_file.close(); cout << endl << endl << "Unencryption Complete" << endl; } }while(choice != 3); return 0; } int menu() { int choice = 0; do { cout << endl << endl; cout << "1. Encrypt File" << endl; cout << "2. Decrypt File" << endl; cout << "3. Exit" << endl << endl; cout << ">"; cin >> choice; }while((choice < 1) || (choice > 3)); return choice; }