Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <sstream>
- #include <iostream>
- using namespace std;
- //global variables
- string stringHolder = "";
- string arr[4];
- double option;
- class Ascii {
- public:
- //outputs the options
- void output() {
- cout<< "1Encrypt-2Decrypt-3Both" << endl;
- cin >> option;
- cout << endl << "Enter String(Dont make it longer than four words):";
- cin.ignore();
- getline(cin,stringHolder);
- }
- //breaks string into words
- void stringBreaker() {
- int i = 0;
- stringstream ssin(stringHolder);
- while (ssin.good() && i < 4){
- ssin >> arr[i];
- ++i;
- }
- for(i = 0; i < 4; i++) {
- cout << arr[i] << endl;
- }
- }
- //breaks string into char array
- void charBreaker() {
- }
- //will output both encrypted and decrypted versions
- string all() {
- stringBreaker();
- return (arr[1], " ", arr[2], " ", arr[3], " ", arr[4]);
- }
- //encrypts to ascii
- string encyrpt() {
- stringBreaker();
- return (arr[1], " ", arr[2], " ", arr[3], " ", arr[4]);
- }
- //decrypts from ascii
- string decrypt() {
- stringBreaker();
- return (arr[1], " ", arr[2], " ", arr[3], " ", arr[4]);
- }
- private:
- //you dont have privates
- };
- int main() {
- //local variables
- string result;
- string output;
- Ascii ascii;
- //output
- ascii.output();
- if (option == 1) {
- result = ascii.encyrpt();
- } else if(option == 2) {
- result = ascii.decrypt();
- } else {
- result = ascii.all();
- }
- cout << "Result " << result;
- system("Pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment