I read about how is an input message prepared to be hashed by MD4,MD5 or SHA-1:

Step1 Append padding bits

The input message is "padded" (extended) so that its length (in bits) equals to 448 mod 512. Padding is always performed, even if the length of the message is already 448 mod 512. Padding is performed as follows: a single "1" bit is appended to the message, and then "0" bits are appended so that the length in bits of the padded message becomes congruent to 448 mod 512. At least one bit and at most 512 bits are appended.

Step2. Append length

A 64-bit representation of the length of the message is appended to the result of step1. If the length of the message is greater than 2^64, only the low-order 64 bits will be used. The resulting message (after padding with bits and with b) has a length that is an exact multiple of 512 bits. The input message will have a length that is an exact multiple of 16 (32-bit) words.

... algorithms steps

I read that hose 2 steps are always the same for input messages for MD4, MD4 and SHA-1. How about SHA-224 / SHA-256 / SHA-384 / SHA-512? How do they 'prepare' input to compute a hash? The same way maybe?


SHA-1, SHA-224 and SHA-256 append the bit “1” to the end of the message, followed by k zero bits, where k is the smallest, non-negative solution to the equation l+1+k ≡ 448 mod 512, where l - message length. In second step they use 32-bit words.

SHA-384, SHA-512, SHA-512/224 and SHA-512/256 use different equation: l+1+k ≡ 896 mod 1024 and in 2. step use 64-bit words.

If you want to learn more, you should read Fips-180-4.

  • 3
    $\begingroup$ Perhaps you should mention where the $448$ and $896$ values come from (it's to have enough space to fit the message length on 32/64 bits at the end of the padding block) $\endgroup$ – Thomas Jul 22 '13 at 13:53
  • 3
    $\begingroup$ So the answer would be "yes, padded using the same method, leaving enough space for the length". The padding is also sometimes used for block ciphers - most people I know simply abbreviate it to "ISO padding" or "bit padding". $\endgroup$ – Maarten Bodewes Jul 22 '13 at 18:01

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.