From 2e34f54ba70cd8a05c39cb3632d2e8acb1d7d72a Mon Sep 17 00:00:00 2001 From: Mohamed Ashraf Date: Mon, 2 Mar 2026 23:52:30 +0400 Subject: [PATCH] fix(hasher): USE OPENSSL --- Minecraft.World/Hasher.cpp | 28 +++++++++++++++++++++++++-- Minecraft.World/MobEffect.cpp | 3 ++- Minecraft.World/MobEffectInstance.cpp | 3 ++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Minecraft.World/Hasher.cpp b/Minecraft.World/Hasher.cpp index bbf47d418..ea94686f4 100644 --- a/Minecraft.World/Hasher.cpp +++ b/Minecraft.World/Hasher.cpp @@ -1,6 +1,12 @@ #include "stdafx.h" +#if defined(_WIN32) #include - +#else +#include +#include +#include +#include +#endif // _WIN32 #include "Hasher.h" Hasher::Hasher(wstring &salt) @@ -10,6 +16,7 @@ Hasher::Hasher(wstring &salt) wstring Hasher::getHash(wstring &name) { +#if defined(_WIN32) // 4J Stu - Removed try/catch //try { wstring s = wstring( salt ).append( name ); @@ -25,4 +32,21 @@ wstring Hasher::getHash(wstring &name) //{ // throw new RuntimeException(e); //} -} \ No newline at end of file +#else + // adapted from a SSL example + std::wstring combined = salt + name; + std::string combined_str(combined.begin(), combined.end()); + unsigned char result[MD5_DIGEST_LENGTH]; + MD5_CTX md5_ctx; + MD5_Init(&md5_ctx); + MD5_Update(&md5_ctx, combined_str.c_str(), combined_str.size()); + MD5_Final(result, &md5_ctx); + std::stringstream ss; + for (int i = 0; i < MD5_DIGEST_LENGTH; i++) + { + ss << std::setw(2) << std::setfill('0') << std::hex << (int)result[i]; + } + std::string hash_str = ss.str(); + return std::wstring(hash_str.begin(), hash_str.end()); +#endif +} diff --git a/Minecraft.World/MobEffect.cpp b/Minecraft.World/MobEffect.cpp index f9687a15a..d7d648b3d 100644 --- a/Minecraft.World/MobEffect.cpp +++ b/Minecraft.World/MobEffect.cpp @@ -4,6 +4,7 @@ #include "net.minecraft.world.food.h" #include "net.minecraft.world.effect.h" #include "SharedConstants.h" +#include "../Minecraft.Client/Windows64Media/strings.h" MobEffect *MobEffect::effects[NUM_EFFECTS]; @@ -267,4 +268,4 @@ bool MobEffect::isDisabled() eMinecraftColour MobEffect::getColor() { return color; -} \ No newline at end of file +} diff --git a/Minecraft.World/MobEffectInstance.cpp b/Minecraft.World/MobEffectInstance.cpp index 1e15e58cf..fca51e4bc 100644 --- a/Minecraft.World/MobEffectInstance.cpp +++ b/Minecraft.World/MobEffectInstance.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "net.minecraft.world.effect.h" +#include "../Minecraft.Client/Windows64/Windows64_App.h" void MobEffectInstance::_init(int id, int duration, int amplifier) { @@ -136,4 +137,4 @@ wstring MobEffectInstance::toString() bool MobEffectInstance::equals(MobEffectInstance *obj) { return this->id == obj->id && this->amplifier == obj->amplifier && this->duration == obj->duration; -} \ No newline at end of file +}