Encrypt PW Nos


SUBMITTED BY: Guest

DATE: June 25, 2014, 7:06 p.m.

FORMAT: C++

SIZE: 1.6 kB

HITS: 769

  1. std::string TPacketCypher::DecryptPasswordString(std::string passwordstring)
  2. {
  3. std::stringstream ss;
  4. std::string temppasswordstring, restoredpassword;
  5. int hex, count = 1;
  6. //Wenn Password gerade dann erste 2 Chars löschen ansonsten 3
  7. if(passwordstring.length() %2 == 0)
  8. {
  9. passwordstring.erase(0, 2);
  10. } else
  11. {
  12. passwordstring.erase(0, 3);
  13. }
  14. //Jeden zweiten Buchstaben zusammenfügen und anschließend nen Leerzeichen setzen
  15. for(auto i = 1; i < passwordstring.length(); i+=2, count++)
  16. {
  17. temppasswordstring += passwordstring[i];
  18. if(count %2 == 0)
  19. {
  20. temppasswordstring += ' ';
  21. }
  22. }
  23. //Bytes in String umwandeln
  24. ss.str(temppasswordstring);
  25. while(ss >> std::hex >> hex)
  26. {
  27. restoredpassword.push_back(hex);
  28. }
  29. return restoredpassword;
  30. }
  31. //------------------------------------------------------------
  32. std::string TPacketCypher::EncryptGamePacket(std::string str)
  33. {
  34. std::string encrypted_string;
  35. int length = str.length();
  36. int secondlength = (length / 122);
  37. int zaehler = 0;
  38. //Packet encrypten
  39. for (int i = 0 ; i < length; i++)
  40. {
  41. if(i == (122 * zaehler))
  42. {
  43. if(secondlength == 0)
  44. {
  45. encrypted_string += abs((((length / 122) * 122) - length));
  46. } else
  47. {
  48. encrypted_string += 0x7A;
  49. secondlength--;
  50. zaehler++;
  51. }
  52. }
  53. encrypted_string += str[i] ^ 0xFF;
  54. }
  55. encrypted_string += (unsigned)0xFF;
  56. return encrypted_string;
  57. }

comments powered by Disqus