Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void cryptonise();
- void decryptonise();
- void more_info();
- int main()
- {
- system("title Shahin's crypto-machine");
- while(true)
- {
- string choice;
- do
- {
- system("cls");
- cout <<"What would you like to do?\n"
- <<"1. Encrypt a string of text\n"
- <<"2. Decrypt a string of text\n"
- <<"3. More info\n"
- <<"4. Exit program\n\n";
- cout <<"Your choice?: ";
- cin>>choice;
- cout <<endl<<endl;
- }while(choice !="1" && choice !="2" && choice != "3" && choice != "4");
- system("cls");
- if(choice=="4") return 0;
- if(choice=="1") cryptonise();
- else if(choice=="2")decryptonise();
- else more_info();
- }
- return 0;
- }
- void cryptonise()
- {
- string text;
- cout <<"What would you like to \"cryptonise\"?:\n";
- cin.get(); getline(cin,text);
- cout <<"\nEncrypted text:\n";
- for(int i=0; i<text.size(); i++)
- {
- int coop = text[i];
- if(i%2==0)
- {
- cout <<(char)(coop+33);
- }
- else
- {
- cout <<(char) (coop+18);
- }
- }
- cout<<endl<<"\nPress [ENTER] to go back to the menu.";cin.get();
- }
- void decryptonise()
- {
- string text2;
- cout <<"What would you like to \"decryptonise\"?:\n";
- cin.get(); getline(cin,text2);
- cout <<"\nDecrypted text:\n";
- for(int i=0; i<text2.size(); i++)
- {
- int coop2 = text2[i];
- if(i%2==0)
- {
- cout <<(char)(coop2-33);
- }
- else
- {
- cout <<(char) (coop2-18);
- }
- }
- cout<<endl<<"\nPress [ENTER] to go back to the menu.";cin.get();
- }
- void more_info()
- {
- system("cls");
- cout <<"When you start this program, you can either \n* encrypt text,\n* decrypt text(text that has been encrypted by a copy of this program)\n* exit the program.";
- cout <<"\n\nYou can copy encrypted text(to send to someone)\nor paste some encrypted text that you want to decrypt by:\n\n"
- <<"* Right click in the program, and select the choice to mark text.\n When you have done so, right click on the highlighted text.\n\n"
- <<"* Right click in the program and select paste\n";
- cout <<"\nPress [ENTER] to go back to the menu.";cin.get();cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement