SHA-256 Hashing problem from binary values For a school project we have been given some example hexadecimal numbers to hash like the following: 

Len = 2 (in bits)
Msg = c0
SHA 256 - MD = 1e1cea10a23697dc97b423c259842ac12ee679d6b43f088f3c32b26dbbfb0d79


The binary representation of c0 is 11000000, but as the length is 2 units, I assume that the binary number to be hashed is 11, which corresponds to 3 in decimal. Using online hash converters, I cannot get the example hash value back. What am I doing wrong?
You need to hash exactly 2 bits set to 1. Two bits need to be padded, remembering that this is the last block. In that case the result is correct.

Note that representing two bits with hex value C0 is not correct. C0 represents a full byte and there is no reason to use the most significant bits rather than the lowest significant bits. Two bits set to one should simply be represented as 11 in binary.



I calculated the required result by performing a digest of the value E0 (the value with an additional padding bit set to 1, and the rest 0 valued padding bits: 11 1 0 0000), skipping the usual padding byte 80 (or 1000 0000 in binary), padding with zero valued bytes and then finally setting the (internal, encoded) length to 2. A bit messy, but it works.