aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-04-17 06:10:30 +0200
committerest31 <MTest31@outlook.com>2015-04-17 06:10:30 +0200
commitf0a1379e5a9ebc954e95d07c1ad5d71587adc6bc (patch)
tree38114d9be2e6bf1a0740035c41d5925c23f5036f /src/util
parent821d0025da3d7dec662e75c6ce2ea32e86aec508 (diff)
downloadminetest-f0a1379e5a9ebc954e95d07c1ad5d71587adc6bc.tar.gz
minetest-f0a1379e5a9ebc954e95d07c1ad5d71587adc6bc.tar.bz2
minetest-f0a1379e5a9ebc954e95d07c1ad5d71587adc6bc.zip
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.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/string.cpp5
-rw-r--r--src/util/string.h3
2 files changed, 5 insertions, 3 deletions
diff --git a/src/util/string.cpp b/src/util/string.cpp
index 02a0586e7..c0f0e97fd 100644
--- a/src/util/string.cpp
+++ b/src/util/string.cpp
@@ -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();
diff --git a/src/util/string.h b/src/util/string.h
index dc520e3a8..d4bbafd9f 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -43,7 +43,8 @@ wchar_t *narrow_to_wide_c(const char *str);
std::wstring narrow_to_wide(const std::string &mbs);
std::string wide_to_narrow(const std::wstring &wcs);
-std::string translatePassword(std::string playername, std::wstring password);
+std::string translatePassword(const std::string &playername,
+ const std::string &password);
std::string urlencode(std::string str);
std::string urldecode(std::string str);
u32 readFlagString(std::string str, const FlagDesc *flagdesc, u32 *flagmask);