sha1 collision of less than 512 bit
Question: In Wikipedia [SHA-1 pseudocode](https://en.wikipedia.org/wiki/SHA-1), it's
said:

> Pre-processing: append the bit '1' to the message e.g. by adding 0x80 if
> message length is a multiple of 8 bits. append 0 ≤ k < 512 bits '0', such
> that the resulting message length in bits

So is it same with `\x01` and `x00\x01`?

Python example:

    
    
    import hashlib
    for s in ('01', '0001'):
        m=hashlib.sha1()
        m.update(s.decode('hex'))
        print m.hexdigest()
    
    >>>bf8b4530d8d246dd74ac53a13471bba17941dff7
    >>>0e356ba505631fbf715758bed27d503f8b260e3a
    

It turns out not to be the same, why?


Answer: **`\x01` and `\x0001` cannot be the same after pre-processing.**

I think that you misunderstand the pseudocode in
[Wiki](https://en.wikipedia.org/wiki/SHA-1). Here I take `\x01` and `\x0001`
as examples, which their length are less than `512` bits.

(Now suppose that the original message length is less than `448` bits)

  * first step: fill in to let its length **=448 (mod 512)**. We append the `1` bit first, then append `0`.

Thus, for `\x01`, it becomes `\x01800000...000`, and its length is 448 bits,
and the ellipsis represents `0` in **hex**.

  * second step: fill in the length. We should add the reminder `(512 - 448) = 64` bits to represent its original length. 

Thus, for `\x01`, its original length is `8`, it shall append `\x00000000
00000008`.

From mentioned above, after pre-processing, `\x01` becomes `\x01800000...08`,
and whole length is 512, and the ellipsis represents `0` in **hex**.

