Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main(int argc, const char * argv[]) {
  7.  
  8. const int cipherLength = 26;
  9. vector<char> normalV(26);
  10. vector<char> cipherV(26);
  11. string toDec = "";
  12. string beenDec = "";
  13. int i = 0;
  14. int k = 0;
  15.  
  16. //cipher character association in vector
  17. normalV.at(i) ='a'; cipherV.at(i) = '!';
  18. normalV.at(i) ='b'; cipherV.at(i) = '^';
  19. normalV.at(i) ='c'; cipherV.at(i) = '&';
  20. normalV.at(i) ='d'; cipherV.at(i) = '*';
  21. normalV.at(i) ='e'; cipherV.at(i) = '@';
  22. normalV.at(i) ='f'; cipherV.at(i) = '(';
  23. normalV.at(i) ='g'; cipherV.at(i) = ')';
  24. normalV.at(i) ='h'; cipherV.at(i) = '-';
  25. normalV.at(i) ='i'; cipherV.at(i) = '#';
  26. normalV.at(i) ='j'; cipherV.at(i) = '_';
  27. normalV.at(i) ='k'; cipherV.at(i) = '=';
  28. normalV.at(i) ='l'; cipherV.at(i) = '+';
  29. normalV.at(i) ='m'; cipherV.at(i) = '[';
  30. normalV.at(i) ='n'; cipherV.at(i) = '{';
  31. normalV.at(i) ='o'; cipherV.at(i) = '$';
  32. normalV.at(i) ='p'; cipherV.at(i) = ']';
  33. normalV.at(i) ='q'; cipherV.at(i) = '}';
  34. normalV.at(i) ='r'; cipherV.at(i) = ';';
  35. normalV.at(i) ='s'; cipherV.at(i) = ':';
  36. normalV.at(i) ='t'; cipherV.at(i) = ',';
  37. normalV.at(i) ='u'; cipherV.at(i) = '%';
  38. normalV.at(i) ='v'; cipherV.at(i) = '<';
  39. normalV.at(i) ='w'; cipherV.at(i) = '.';
  40. normalV.at(i) ='x'; cipherV.at(i) = '>';
  41. normalV.at(i) ='y'; cipherV.at(i) = '/';
  42. normalV.at(i) ='z'; cipherV.at(i) = '?';
  43.  
  44.  
  45.  
  46. // Get secret message input
  47. do {
  48. cout << "Enter a secret message: ";
  49. getline(cin, toDec);
  50. } while (toDec.length() == 0);
  51.  
  52. beenDec = toDec;
  53.  
  54. //need to create a loop to go through vector and replace all instances of cipher
  55. //need to loop through input string and compare each char against vector
  56.  
  57. // Decrypt secret message
  58.  
  59. //input string
  60. for (i = 0; i < toDec.length(); i++)
  61. {
  62. //character comparison
  63. for(k = 0; k < cipherLength; ++k)
  64. {
  65.  
  66. if (toDec.at(i) == cipherV.at(k))
  67. {
  68. beenDec.at(i) = normalV.at(k);
  69. }
  70. }
  71. }
  72. cout << "Decrypted message: " << beenDec << endl;
  73.  
  74.  
  75.  
  76. return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement