Advertisement
MorpheusArch

Untitled

Apr 6th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. //This program is free software: you can redistribute it and/or modify
  2. //it under the terms of the GNU General Public License as published by
  3. //the Free Software Foundation, either version 3 of the License, or
  4. //(at your option) any later version.
  5.  
  6. //This program is distributed in the hope that it will be useful,
  7. //but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9. //GNU General Public License for more details.
  10.  
  11. //You should have received a copy of the GNU General Public License
  12. //along with this program.  If not, see <http://www.gnu.org/licenses/>.
  13.  
  14.  
  15. #include <iostream>
  16. #include <string>
  17.  
  18. using namespace std;
  19.  
  20.  
  21.  
  22. string XOR(string data, char key[])     //this is the encryption function
  23.  
  24. {
  25.    
  26.     string xorstring = data; //initialise variable for XOR data input
  27.     for (int i = 0; i <xorstring.size(); i++) {     //loop scrambling bits in string
  28.         xorstring[i] = data[i] ^ key[i % (sizeof(key) / sizeof(char))];     //scrambles string
  29.     }
  30.     return xorstring;
  31. }
  32.  
  33. //XOR Function now works both ways.
  34.  
  35. int main()
  36.  
  37. {
  38.     char key [3] = { 'K', 'E', 'Y' };
  39.     std::cout << XOR("morpheusarch", key);  //replace morpheusarch for whatever you want. could call other functions
  40.     cout << data;
  41.     getchar ();
  42.     return 0;
  43.    
  44.    
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement