1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Refactor around translatePassword

Change types for passed password from wstring to string, which removes converting
back and forth in most cases. Move the narrow_to_wide conversion, where its neccessary,
closer to irrlicht. Remove trailing spaces in guiPasswordChange.cpp. Make parameters for
translatePassword passed as const reference.
This commit is contained in:
est31 2015-04-17 06:10:30 +02:00
parent 821d0025da
commit f0a1379e5a
8 changed files with 24 additions and 22 deletions

View file

@ -181,12 +181,13 @@ std::string wide_to_narrow(const std::wstring &wcs)
// their password. (Exception : if the password field is
// blank, we send a blank password - this is for backwards
// compatibility with password-less players).
std::string translatePassword(std::string playername, std::wstring password)
std::string translatePassword(const std::string &playername,
const std::string &password)
{
if (password.length() == 0)
return "";
std::string slt = playername + wide_to_narrow(password);
std::string slt = playername + password;
SHA1 sha1;
sha1.addBytes(slt.c_str(), slt.length());
unsigned char *digest = sha1.getDigest();