aboutsummaryrefslogtreecommitdiff
path: root/src/utility.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-05-23 00:12:24 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-05-23 00:12:24 +0300
commite1a2b8f600ff9845ecff0f06c85d4d2c29970414 (patch)
tree6b948bf2bb238232f2d6faea84b70bafb8eaae89 /src/utility.cpp
parent4a6b9a6ac1b07239474bce8d3ebf772ce75e862e (diff)
parenta8a3271470299820c5322523dc439415bc1ff8a0 (diff)
downloadhax-minetest-server-e1a2b8f600ff9845ecff0f06c85d4d2c29970414.tar.gz
hax-minetest-server-e1a2b8f600ff9845ecff0f06c85d4d2c29970414.zip
merged password change menu
Diffstat (limited to 'src/utility.cpp')
-rw-r--r--src/utility.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/utility.cpp b/src/utility.cpp
index fc657b27b..186881c5a 100644
--- a/src/utility.cpp
+++ b/src/utility.cpp
@@ -23,6 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "utility.h"
#include "gettime.h"
+#include "sha1.h"
+#include "base64.h"
TimeTaker::TimeTaker(const char *name, u32 *result)
{
@@ -217,3 +219,24 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 range,
return true;
}
+// Get an sha-1 hash of the player's name combined with
+// the password entered. That's what the server uses as
+// 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)
+{
+ if(password.length() == 0)
+ return "";
+
+ std::string slt=playername + wide_to_narrow(password);
+ SHA1 *sha1 = new SHA1();
+ sha1->addBytes(slt.c_str(), slt.length());
+ unsigned char *digest = sha1->getDigest();
+ std::string pwd = base64_encode(digest, 20);
+ free(digest);
+ return pwd;
+}
+
+
+