Decompile fn_00121 (MD5::MD5)

Batch #860 by ragnarok-clanker: 1 byte-identical, 0 confirmed by peer review.

- fn_00121 MD5::MD5: byte-identical

Merged automatically: every function is byte-identical to the original.
Adds to the build: Source/Utility/MD5.cpp
This commit is contained in:
ragnarok-clanker 2026-10-25 19:41:16 +00:00
commit 5fcef82f97
3 changed files with 86 additions and 0 deletions

48
Source/Utility/MD5.cpp Normal file
View file

@ -0,0 +1,48 @@
#include "Utility/MD5.h"
#include <cstring>
#include <cwchar>
#include <windows.h>
namespace {
// INLINED
inline std::uint32_t FoldDigest(const unsigned char* digest) {
return ((digest[0] ^ digest[1] ^ digest[2] ^ digest[3]) << 8)
| (digest[4] ^ digest[5] ^ digest[6] ^ digest[7])
| ((digest[8] ^ digest[9] ^ digest[10] ^ digest[11]) << 16)
| (static_cast<std::uint32_t>(digest[12] ^ digest[13] ^ digest[14] ^ digest[15]) << 24);
}
}
// FUNCTION: fn_00121
MD5::MD5() {
}
#define MD5_F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
#define MD5_F2(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
#define MD5_F3(x, y, z) ((x) ^ (y) ^ (z))
#define MD5_F4(x, y, z) ((y) ^ ((x) | ~(z)))
#define MD5_STEP(f, a, b, c, d, x, s, t) do { \
(a) += f((b), (c), (d)) + (x) + (t); \
(a) = (((a) << (s)) | ((a) >> (32 - (s)))) + (b); \
} while (0)
#undef MD5_STEP
#undef MD5_F4
#undef MD5_F3
#undef MD5_F2
#undef MD5_F1

37
Source/Utility/MD5.h Normal file
View file

@ -0,0 +1,37 @@
#ifndef RAGNAROK_SOURCE_UTILITY_MD5_H
#define RAGNAROK_SOURCE_UTILITY_MD5_H
#include <cstdint>
class MD5 {
public:
MD5();
~MD5();
int Initialize();
void Update(const unsigned char* input, std::uint32_t length);
unsigned char* Finalize();
unsigned char* DigestBuffer(const unsigned char* input, std::uint32_t length, unsigned char* digest);
std::uint32_t HashBuffer(const unsigned char* input, std::uint32_t length);
std::uint32_t HashString(const char* text);
std::uint32_t HashString(const wchar_t* text);
std::uint32_t HashFile(const wchar_t* filename);
std::uint32_t HashStringLower(const char* text);
std::uint32_t HashStringLower(const wchar_t* text);
std::uint32_t HashFile(const char* filename);
private:
const unsigned char* Decode(std::uint32_t* output, const unsigned char* input, std::uint32_t count);
std::uint32_t* Transform(std::uint32_t* state, const std::uint32_t* input);
union {
/* 0000 */ unsigned char m_buffer[64];
/* 0000 */ std::uint32_t m_words[16];
};
/* 0040 */ std::uint32_t m_state[4];
/* 0050 */ std::uint32_t m_byteCount[2];
};
static_assert(sizeof(MD5) == 0x58);
#endif

View file

@ -574,6 +574,7 @@
"Source/Utility/Async/NRecycleObjectPoolMgr.cpp": 0,
"Source/Utility/Base64.cpp": 0,
"Source/Utility/GuidParse.cpp": 0,
"Source/Utility/MD5.cpp": 0,
"Source/Utility/Math/AffineLookAt.cpp": 0,
"Source/Utility/Math/AffineMatrix.cpp": 0,
"Source/Utility/Math/ClientAngles.cpp": 0,