Reputation: 145
I finished a implementation of MD5 algorithm in C++, but it doesn't work properly... My Hashes aren't correct.
Just for understanding: If I try to Hash a File (64 byte) with MD5 hash algorithm the following have to happen:
// 512 Bit(data) 512 Bit(Padding)
// ------------- -------------
// |xxxxxxxxxxx| |10000000|64|
// ------------- -------------
//
// 1 - appended 1 Bit
// 0 - filled with zeros until 8 bytes before end of block
// 64 - 64 bit (8 Byte) representation of size of file
1st: MD5 algorithm with data block
2nd: create additional block with Padding
3rd: MD5 algorithm with Padding Block
Right?
Upvotes: 1
Views: 84
Reputation: 145
The value of the 64-Bit representation MUST be in Bits, not Bytes! Therefore the counter, in my case, isn't 64. It is 64*8 = 512.
Upvotes: 1