Advertisement
Redaciple00

Untitled

Oct 4th, 2022
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. std::wstring SecurityData::HashPassword(const std::wstring& pwd)
  2. {
  3.     const unsigned int seed = [&pwd]() {
  4.         unsigned int seed = 0;
  5.         for (int i = 1; i < pwd.size(); i += 2) {
  6.             seed += (unsigned int)pwd[i] % 256;
  7.         }
  8.         return seed;
  9.     }();
  10.  
  11.     std::srand(seed);
  12.  
  13.     const int key = (std::rand() % 256) + (std::rand() % 256) * (std::rand() % 256);
  14.  
  15.     // magic.size() % 2 must be 0
  16.     std::wstring magic = L"12345678";
  17.    
  18.     for (int i = 0; i < magic.size() * sizeof(wchar_t) / sizeof(int); ++i) {
  19.         int* begin_ptr = (int*) (&magic[0] + i * sizeof(int) / sizeof(wchar_t));
  20.         *begin_ptr = *begin_ptr ^ key;
  21.     }
  22.  
  23.     return magic;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement