#include #include #include using namespace std; int main() { int shift(0); char c, shifted_c; string text; ifstream inputfile("shift-cipher-encoded.txt"); ofstream outputfile("OUTPUT"); if (!inputfile) { cout << "Could not open input file.\n"; system("PAUSE"); exit(1); } if(!getline(inputfile, text, char(0))) exit(1); cout << "Hello, enter a shift amount: "; cin >> shift; for (int i = 0; i < text.length(); i++) { c = text[i]; if( c >= '0' && c <= '9' ) { shifted_c = c - '0'; shifted_c += 10 + shift; shifted_c %= 10; shifted_c += '0'; } else if (c >= 'a' && c <= 'z') { shifted_c = c - 'a'; shifted_c += 26 + shift; shifted_c %= 26; shifted_c += 'a'; } else if (c >= 'A' && c <= 'Z') { shifted_c = c - 'A'; shifted_c += 26 + shift; shifted_c %= 26; shifted_c += 'A'; } else { shifted_c = c; } outputfile << shifted_c; } inputfile.close(); outputfile.close(); cout << "I'm done encrypting your love note. See file OUTPUT. Adios!\n\n"; system("PAUSE"); return 0; }