/************************************************************************************************************************************************************************ * Encoder/Decoder * Charles Wood-Henderson * To encrypt strings and decrypt them. * Acknowledgements: none ************************************************************************************************************************************************************************/ #include #include using namespace std; /*********************************************************************************************************************************************************************** * cipher() * none * class * To encode/decode strings. ************************************************************************************************************************************************************************/ class cipher { private: string line; int shift_key; public: cipher() : shift_key(0) { } void encode(); void decode(); }; /*********************************************************************************************************************************************************************** * main() * none * int * Required to run the program. ***********************************************************************************************************************************************************************/ int main() { cipher cipher1; // creating a class string do_what; // creating a string to see what the user wants to do bool repeat = true; while(repeat == true) { cout << "Welcome to the Caesar Encoder/Decoder!\n" << "Would you like to encode or decode or quit? "; cin >> do_what; if(do_what == "encode") { cipher1.encode(); // seeing what the user wants to do } else if(do_what == "decode") { cipher1.decode(); // seeing what the user wants to do } else if(do_what == "quit") { // seeing what the user wants to do return 0; } } } void cipher::encode() { bool uppercase = false; cout << "Please enter a string that you would like to encode: "; cin >> line; do { cout << "What integer cipher shift key will you use? (1-20) "; cin >> shift_key; int length = line.length(); for(int j=0; j 'z' && uppercase == false) { int k = line.at(j) - 'z'; // checking if the places shifted goes over z when its lowercase line.at(j) = 'a' + k - 1; } if(line.at(j) > 'Z' && uppercase == true) { int k = line.at(j) - 'Z'; // checking if the places shifted goes over Z when its uppercase line.at(j) = 'A' + k - 1; } } cout << "Your encoded string is:\n"; for(int j=0; j> line; cout << "What integer cipher shift key will you use? (1-20) "; cin >> shift_key; int length = line.length(); for(int j=0; j