Advertisement
Guest User

Untitled

a guest
Nov 29th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. int main(){
  5. srand(time(0));
  6. std::cout << "Welcome, to the scrambler: " << std::endl;
  7. std::cout << "Enter the string(all lowercase letters) you want to be scrambled: " << std::endl;
  8. std::string user_password;
  9. std::cin >> user_password;
  10.  
  11.  
  12. std::cout << "Select the type of encryption you want: " << std::endl;
  13. std::cout << "1. Standard alphabet scrambler " << std::endl;
  14. //Add support for other types...
  15. int choice = 0;
  16. std::cin >> choice;
  17.  
  18. if (choice == 1) {
  19.  
  20. std::vector<char> vuser_pass;
  21.  
  22. for ( decltype(user_password.size()) i = 0; i <= user_password.size(); ++i ) {
  23. char letter_hold = user_password[i];
  24. vuser_pass.push_back(letter_hold);
  25. }
  26. //for ( decltype(vuser_pass.size()) i = 0; i <= vuser_pass.size(); ++i) {
  27. //std::cout << vuser_pass.at(i) << std::endl;
  28. //}
  29.  
  30. std::string alpha = "abcdefghijklmnopqrstuvwxyz";
  31. std::vector<char> valpha;
  32.  
  33.  
  34. for ( decltype(alpha.size()) cnt = 0; cnt <= alpha.size(); ++cnt) {
  35.  
  36. valpha.push_back(alpha[cnt]);
  37. }
  38.  
  39.  
  40. //for ( decltype(valpha.size()) cnt = 0; cnt <= valpha.size(); ++cnt) {
  41. //std::cout << valpha[cnt] << std::endl;
  42.  
  43. //}
  44.  
  45. auto limit = vuser_pass.size();
  46. limit -= 1;
  47.  
  48. for ( decltype(vuser_pass.size()) sindex = 0; sindex < limit; ++sindex ) {
  49. decltype(valpha.size()) vindex = rand() % 25;
  50. vuser_pass[sindex] = valpha.at(vindex);
  51. }
  52.  
  53. for ( decltype(vuser_pass.size()) i = 0; i < vuser_pass.size(); ++i) {
  54. std::cout << vuser_pass.at(i);
  55. }
  56.  
  57. }
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement