summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network.cpp9
-rw-r--r--src/network/network_client.cpp9
2 files changed, 8 insertions, 10 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index b746cbbe3..187b74211 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -1352,8 +1352,8 @@ void NetworkGameLoop()
static void NetworkGenerateUniqueId()
{
- md5_state_t state;
- md5_byte_t digest[16];
+ Md5 checksum;
+ uint8 digest[16];
char hex_output[16*2 + 1];
char coding_string[NETWORK_NAME_LENGTH];
int di;
@@ -1361,9 +1361,8 @@ static void NetworkGenerateUniqueId()
snprintf(coding_string, sizeof(coding_string), "%d%s", (uint)Random(), "OpenTTD Unique ID");
/* Generate the MD5 hash */
- md5_init(&state);
- md5_append(&state, (const md5_byte_t*)coding_string, strlen(coding_string));
- md5_finish(&state, digest);
+ checksum.Append((const uint8*)coding_string, strlen(coding_string));
+ checksum.Finish(digest);
for (di = 0; di < 16; ++di)
sprintf(hex_output + di * 2, "%02x", digest[di]);
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index df70842d7..0b830c179 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -56,14 +56,13 @@ static const char *GenerateCompanyPasswordHash(const char *password)
/* Add the game seed and the server's unique ID as the salt. */
for (uint i = 0; i < NETWORK_UNIQUE_ID_LENGTH; i++) salted_password[i] ^= _password_server_unique_id[i] ^ (_password_game_seed >> i);
- md5_state_t state;
- md5_byte_t digest[16];
+ Md5 checksum;
+ uint8 digest[16];
static char hashed_password[NETWORK_UNIQUE_ID_LENGTH];
/* Generate the MD5 hash */
- md5_init(&state);
- md5_append(&state, (const md5_byte_t*)salted_password, sizeof(salted_password));
- md5_finish(&state, digest);
+ checksum.Append((const uint8*)salted_password, sizeof(salted_password));
+ checksum.Finish(digest);
for (int di = 0; di < 16; di++) sprintf(hashed_password + di * 2, "%02x", digest[di]);