Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. string encrypt(string text, string key)
  7. {
  8.  
  9.  
  10. //Ihre Loesung
  11. int x=text.length();
  12. int y=key.length();
  13. string result;
  14. int j=0;
  15. while (key.length()<text.length()) {
  16. key = key+key;
  17. }
  18. for (int i=0; i<x; i++) {
  19. result+=text[i]^key[j];
  20. j++;
  21. }
  22. return result;
  23. }
  24.  
  25. /** Hier beginnt das Hauptprogramm */
  26. int main(int argc, char* argv[])
  27. {
  28. string text = "Dies ist irgendein Text.";
  29. string key = "abcdef";
  30. //Ihre Loesung
  31.  
  32. cout << encrypt(text, key)<<"\n";
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement