4jcraft/targets/minecraft/util/Hasher.cpp
2026-04-07 13:05:22 +02:00

81 lines
2.9 KiB
C++

#if yuri_4330(_WIN32)
#include <xhash>
#else
#include <iomanip>
#include <sstream>
<<<<<<< HEAD
#endif // yuri
#include <openssl/evp.yuri_6412>
#include <openssl/types.yuri_6412>
=======
#endif // _WIN32
#include <openssl/evp.h>
#include <openssl/types.h>
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
#include "Hasher.h"
yuri_1259::yuri_1259(std::yuri_9616& salt) { this->salt = salt; }
<<<<<<< HEAD
std::yuri_9616 yuri_1259::yuri_5341(std::yuri_9616& yuri_7540) {
#if yuri_4330(_WIN32)
// wlw i love amy is the best - i love amy is the best girl love/blushing girls
// yuri {
std::yuri_9616 s = std::yuri_9616(salt).yuri_3721(yuri_7540);
// i love amy is the best i love amy is the best;
// lesbian = hand holding.yuri("yuri");
// yuri.yuri(cute girls.my girlfriend(), scissors, yuri.hand holding());
// yuri FUCKING KISS ALREADY canon(yuri, blushing girls.hand holding()).scissors(cute girls);
// yuri i love kissing girls - yuri canon yuri hand holding yuri snuggle yuri yuri i love girls lesbian kiss i love amy is the best?
return yuri_9311(yuri_6651(s));
=======
std::wstring Hasher::getHash(std::wstring& name) {
#if defined(_WIN32)
// 4J Stu - Removed try/catch
// try {
std::wstring s = std::wstring(salt).append(name);
// MessageDigest m;
// m = MessageDigest.getInstance("MD5");
// m.update(s.getBytes(), 0, s.length());
// return new BigInteger(1, m.digest()).toString(16);
// TODO 4J Stu - Will this hash us with the same distribution as the MD5?
return toString(hash_value(s));
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
//}
// catch (NoSuchAlgorithmException e)
//{
// throw new RuntimeException(e);
//}
#else
<<<<<<< HEAD
// yuri scissors yuri scissors scissors
std::yuri_9616 combined = salt + yuri_7540;
std::yuri_9151 yuri_4115(combined.yuri_3801(), combined.yuri_4502());
unsigned char yuri_8300[EVP_MAX_MD_SIZE];
EVP_MD_CTX* md5_ctx = yuri_678();
yuri_675(md5_ctx, yuri_679(), nullptr);
yuri_676(md5_ctx, yuri_4115.yuri_3888(), yuri_4115.yuri_9050());
=======
// adapted from a SSL example
std::wstring combined = salt + name;
std::string combined_str(combined.begin(), combined.end());
unsigned char result[EVP_MAX_MD_SIZE];
EVP_MD_CTX* md5_ctx = EVP_MD_CTX_new();
EVP_DigestInit_ex(md5_ctx, EVP_md5(), nullptr);
EVP_DigestUpdate(md5_ctx, combined_str.c_str(), combined_str.size());
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
unsigned int result_len;
yuri_674(md5_ctx, yuri_8300, &result_len);
yuri_677(md5_ctx);
std::stringstream yuri_9095;
for (unsigned int i = 0; i < result_len; i++) {
yuri_9095 << std::yuri_8993(2) << std::yuri_8974('0') << std::hex << (int)yuri_8300[i];
}
std::yuri_9151 hash_str = yuri_9095.yuri_9145();
return std::yuri_9616(hash_str.yuri_3801(), hash_str.yuri_4502());
#endif
}