stoneharry

Untitled

Jun 18th, 2012
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1.     // Hash the session key so that the logon DB can know
  2.     //char HASH_CONSTANT = 0x7A0B;
  3.  
  4.     //const char* temp = m_sessionkey.AsHexStr();
  5.     /*SHA1_CONTEXT sha_context;
  6.     SHA1_Init(&sha_context);
  7.     SHA1_Update(&sha_context, temp, 40);
  8.     SHA1_Update(&sha_context, &HASH_CONSTANT, 2);
  9.     char keyhash[24];
  10.     SHA1_Final(keyhash, &sha_context);*/
  11.  
  12.     static const unsigned short hash_constant (0x7a0b);
  13.     Sha1Hash newone;
  14.     newone.UpdateBigNumbers (&m_sessionkey, NULL);
  15.     newone.UpdateData ((uint8*)&hash_constant, sizeof (hash_constant));
  16.     newone.Finalize();
  17.     const unsigned char* hashed_session_key (newone.GetDigest());
  18.  
  19.     std::stringstream stream;  
  20.         for(int i = 0; i < 20; i++)
  21.     {
  22.         stream << std::hex << (unsigned int)hashed_session_key[i];
  23.     }
  24.         std::string printable = (stream.str());
  25.  
  26.     // Let the DB know
  27.     sLogonSQL->Execute("UPDATE `account_messages` SET `hash` = '%s' WHERE `account` = '%s';", printable.c_str(), m_account->UsernamePtr);
Advertisement
Add Comment
Please, Sign In to add comment