diff --git a/src/base64.cpp b/src/base64.cpp index 2a863d1..0dfba50 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -71,9 +71,10 @@ std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_ for (j = 0; (j < i + 1); j++) ret += base64_chars[char_array_4[j]]; - - while((i++ < 3)) - ret += '='; + + // Don't pad it with = + /*while((i++ < 3)) + ret += '=';*/ } diff --git a/src/client.cpp b/src/client.cpp index 79bbd80..e494056 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -306,8 +306,14 @@ void Client::step(float dtime) SharedBuffer data(2+1+PLAYERNAME_SIZE+PASSWORD_SIZE); writeU16(&data[0], TOSERVER_INIT); writeU8(&data[2], SER_FMT_VER_HIGHEST); + memset((char*)&data[3], 0, PLAYERNAME_SIZE); snprintf((char*)&data[3], PLAYERNAME_SIZE, "%s", myplayer->getName()); + + /*dstream<<"Client: password hash is \""<addBytes(slt.c_str(), slt.length()); - unsigned char *digest = sha1->getDigest(); + std::string slt = playername + wide_to_narrow(password); + SHA1 sha1; + sha1.addBytes(slt.c_str(), slt.length()); + unsigned char *digest = sha1.getDigest(); std::string pwd = base64_encode(digest, 20); free(digest); return pwd;