diff options
author | Mattes D <github@xoft.cz> | 2014-06-27 19:34:53 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-06-27 19:34:53 +0200 |
commit | 563f706422554d1d8ff1121b9613ab9d34951a3b (patch) | |
tree | 3823d1dd610fafeedea79125706b56cd7b21c9a2 /src | |
parent | CMake: pthread is used only on Unix. (diff) | |
download | cuberite-563f706422554d1d8ff1121b9613ab9d34951a3b.tar cuberite-563f706422554d1d8ff1121b9613ab9d34951a3b.tar.gz cuberite-563f706422554d1d8ff1121b9613ab9d34951a3b.tar.bz2 cuberite-563f706422554d1d8ff1121b9613ab9d34951a3b.tar.lz cuberite-563f706422554d1d8ff1121b9613ab9d34951a3b.tar.xz cuberite-563f706422554d1d8ff1121b9613ab9d34951a3b.tar.zst cuberite-563f706422554d1d8ff1121b9613ab9d34951a3b.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 11 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/ClientHandle.cpp | 22 |
3 files changed, 16 insertions, 19 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index f52d970bf..3692851eb 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -4,7 +4,7 @@ #include "ManualBindings.h" #undef TOLUA_TEMPLATE_BIND #include "tolua++/include/tolua++.h" - +#include "polarssl\md5.h" #include "Plugin.h" #include "PluginLua.h" #include "PluginManager.h" @@ -25,7 +25,6 @@ #include "../BlockEntities/NoteEntity.h" #include "../BlockEntities/MobHeadEntity.h" #include "../BlockEntities/FlowerPotEntity.h" -#include "md5/md5.h" #include "../LineBlockTracer.h" #include "../WorldStorage/SchematicFileSerializer.h" #include "../CompositeChat.h" @@ -2001,9 +2000,11 @@ static int tolua_cPlugin_Call(lua_State * tolua_S) static int tolua_md5(lua_State* tolua_S) { - std::string SourceString = tolua_tostring(tolua_S, 1, 0); - std::string CryptedString = md5( SourceString ); - tolua_pushstring( tolua_S, CryptedString.c_str() ); + unsigned char Output[16]; + size_t len = 0; + const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len); + md5(SourceString, len, Output); + lua_pushlstring(tolua_S, (const char *)Output, ARRAYCOUNT(Output)); return 1; } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 335ce8315..deea92aec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -260,4 +260,4 @@ endif () if (WIN32) target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib) endif() -target_link_libraries(${EXECUTABLE} md5 luaexpat iniFile jsoncpp polarssl zlib lua sqlite) +target_link_libraries(${EXECUTABLE} luaexpat iniFile jsoncpp polarssl zlib lua sqlite) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 46083a8f1..611995148 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -30,7 +30,7 @@ #include "CompositeChat.h" #include "Items/ItemSword.h" -#include "md5/md5.h" +#include "polarssl/md5.h" @@ -239,18 +239,14 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) // xxxxxxxx-xxxx-3xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B // Generate an md5 checksum, and use it as base for the ID: - MD5 Checksum(a_Username); - AString UUID = Checksum.hexdigest(); - UUID[12] = '3'; // Version 3 UUID - UUID[16] = '8'; // Variant 1 UUID - - // Now the digest doesn't have the UUID slashes, but the client requires them, so add them into the appropriate positions: - UUID.insert(8, "-"); - UUID.insert(13, "-"); - UUID.insert(18, "-"); - UUID.insert(23, "-"); - - return UUID; + unsigned char MD5[16]; + md5((const unsigned char *)a_Username.c_str(), a_Username.length(), MD5); + return Printf("%02x%02x%02x%02x-%02x%02x-3%01x%02x-8%01x%02x-%02x%02x%02x%02x%02x%02x", + MD5[0], MD5[1], MD5[2], MD5[3], + MD5[4], MD5[5], MD5[6], MD5[7], + MD5[8], MD5[9], MD5[10], MD5[11], + MD5[12], MD5[13], MD5[14], MD5[15] + ); } |