The original description of the MD5 algorithm initializes the values of A, B, C, and D to the following:

word A: 01 23 45 67
word B: 89 ab cd ef
word C: fe dc ba 98
word D: 76 54 32 10

How were the values determined and does it matter how they were chosen?


1 Answer 1


These are obtained by counting up in base 16 and then counting down in base 16.

Specifically we break the 4x 32-bit words into 32 4-bit pieces and treat each piece of 4-bits as a hex digit (equally you can think of this as breaking each byte in half). We set these first 16 of these hex digits to be the numbers 0, 1 ,2,... f and the next 16 of them to be f, e ,d , c,..., 0.

Incremental counting is considered a natural enough operation that these are not "magic numbers", but rather a good example of "nothing up my sleeve" numbers.

  • $\begingroup$ Addition: the security argument of a Merkle-Damgård hash such as MD5 or SHA-256 requires the Initialization Value of the first round to be a public value chosen non-maliciously. Hence the use of nothing up my sleeve numbers, which are arbitrary enough (contrary to all-zero), but pre-existing or regular (preventing malicious choice). $\endgroup$
    – fgrieu
    Dec 15, 2022 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.