Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main () {
  6.  
  7. string str = "WTAADLDGASXCUDGBPIXDCHTRJGXIN";
  8. string dec = "WTAADLDGASXCUDGBPIXDCHTRJGXIN";
  9. int k = 0;
  10.  
  11. for (int i=1; i<=26; i++) {
  12. k = i;
  13.  
  14. for (int j=0; j<str.size(); j++) {
  15. if (str[j] + k > 'Z') {
  16. dec[j] = (str[j] + k) - 'Z' + 'A' - 1;
  17. } else {
  18. dec[j] = str[j] + k;
  19. }
  20. }
  21.  
  22. cout << dec << '\n';
  23. }
  24.  
  25. cout << '\n';
  26. k = 11;
  27. for (int i=0; i<str.size(); i++) {
  28. if (str[i] + k > 'Z') {
  29. dec[i] = (str[i] + k) - 'Z' + 'A' - 1;
  30. } else {
  31. dec[i] = str[i] + k;
  32. }
  33. }
  34.  
  35. cout << "key K : " << k << '\n';
  36. cout << "plaintext : " << dec << '\n';
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement