2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 10:37:41 -04:00

Actually fix it, thanks to Zrax and Paradox

This commit is contained in:
2012-02-15 01:46:18 -05:00
parent 8bf78c0e35
commit 23911b0a49

View File

@ -93,14 +93,11 @@ void CryptCreateRandomSeed(size_t length, uint8_t* data)
void CryptHashPassword(const plString& username, const plString& password, ShaDigest dest)
{
/* This should be unnecessary once plString has ToLower() */
wchar_t* w_name = (wchar_t*)_TEMP_CONVERT_TO_WCHAR_T(username);
StrLower(w_name);
plString buf = password;
buf += _TEMP_CONVERT_FROM_WCHAR_T(w_name);
plSHAChecksum sum(buf.GetSize() * sizeof(wchar_t), (uint8_t*)_TEMP_CONVERT_TO_WCHAR_T(buf));
plStringStream buf;
buf << password.Left(password.GetSize() - 1) << '\0';
buf << username.ToLower().Left(username.GetSize() - 1) << '\0';
plStringBuffer<uint16_t> result = buf.GetString().ToUtf16();
plSHAChecksum sum(result.GetSize() * sizeof(uint16_t), (uint8_t*)result.GetData());
memcpy(dest, sum.GetValue(), sizeof(ShaDigest));
}