Advertisement
Guest User

Woop

a guest
Jun 14th, 2011
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void cryptonise();
  6. void decryptonise();
  7. void more_info();
  8.  
  9. int main()
  10. {
  11.  
  12.     system("title Shahin's crypto-machine");
  13.  
  14. while(true)
  15.            {
  16.  
  17. string choice;
  18.  
  19. do
  20. {
  21.     system("cls");
  22. cout <<"What would you like to do?\n"
  23.      <<"1. Encrypt a string of text\n"
  24.      <<"2. Decrypt a string of text\n"
  25.      <<"3. More info\n"
  26.      <<"4. Exit program\n\n";
  27.  
  28.     cout <<"Your choice?: ";
  29.     cin>>choice;
  30.     cout <<endl<<endl;
  31. }while(choice !="1" && choice !="2" && choice != "3" && choice != "4");
  32.  
  33. system("cls");
  34.  
  35. if(choice=="4") return 0;
  36. if(choice=="1") cryptonise();
  37. else if(choice=="2")decryptonise();
  38. else more_info();
  39.  
  40.  
  41.  
  42.            }
  43. return 0;
  44. }
  45.  
  46. void cryptonise()
  47. {
  48.     string text;
  49.     cout <<"What would you like to \"cryptonise\"?:\n";
  50.     cin.get();   getline(cin,text);
  51.  
  52.  cout <<"\nEncrypted text:\n";
  53. for(int i=0; i<text.size(); i++)
  54.     {
  55.         int coop = text[i];
  56.  
  57.         if(i%2==0)
  58.         {
  59.             cout <<(char)(coop+33);
  60.         }
  61.         else
  62.         {
  63.             cout <<(char) (coop+18);
  64.         }
  65.     }
  66.  
  67. cout<<endl<<"\nPress [ENTER] to go back to the menu.";cin.get();
  68.  
  69. }
  70.  
  71. void decryptonise()
  72. {
  73.     string text2;
  74.     cout <<"What would you like to \"decryptonise\"?:\n";
  75.      cin.get();   getline(cin,text2);
  76.  
  77.   cout <<"\nDecrypted text:\n";
  78.  
  79. for(int i=0; i<text2.size(); i++)
  80.     {
  81.         int coop2 = text2[i];
  82.  
  83.         if(i%2==0)
  84.         {
  85.             cout <<(char)(coop2-33);
  86.         }
  87.         else
  88.         {
  89.             cout <<(char) (coop2-18);
  90.         }
  91.     }
  92.     cout<<endl<<"\nPress [ENTER] to go back to the menu.";cin.get();
  93. }
  94.  
  95. void more_info()
  96. {
  97.     system("cls");
  98.  
  99.     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.";
  100.     cout <<"\n\nYou can copy encrypted text(to send to someone)\nor paste some encrypted text that you want to decrypt by:\n\n"
  101.          <<"* 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"
  102.          <<"* Right click in the program and select paste\n";
  103.  
  104.          cout <<"\nPress [ENTER] to go back to the menu.";cin.get();cin.get();
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement