Skip to content

Commit

Permalink
MD5: Fix slight inaccuracy in hash function
Browse files Browse the repository at this point in the history
  • Loading branch information
Mefiresu committed Jul 7, 2024
1 parent c3db0fe commit 3258aa3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions RSDKv4/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void GenerateMD5FromString(const char *string, int len, uint *hash0, uint *hash1
// Padding (only 0x80 is needed since memset(0) has been called on hashStream)
hashStream[len] = 0x80;
// Write length in little endian order
for (int p = 0; p < 3; ++p) hashStream[padded_length + p] = (length_bits >> (8 * p));
for (int p = 0; p < 4; ++p) hashStream[padded_length + p] = (length_bits >> (8 * p));

// Process blocks
for (int block = 0; block < padded_length; block += 64) {
Expand All @@ -225,7 +225,7 @@ void GenerateMD5FromString(const char *string, int len, uint *hash0, uint *hash1
}
uint streamVal = 0;
// Convert to little endian
for (int p = 0; p < 4; ++p) streamVal |= (hashStream[block + (idx * 4) + p]) << (8 * p);
for (int p = 0; p < 4; ++p) streamVal |= (hashStream[block + (idx * 4) + p] & 0xFF) << (8 * p);
uint temp = D;
D = C;
C = B;
Expand Down

0 comments on commit 3258aa3

Please sign in to comment.