Calculate mnemonic code from terminal

I want to replicate mnemonic code with terminal. the steps are:

1. Create a random sequence (entropy) of 128 to 256 bits.
2. Create a checksum of the random sequence by taking the first (entropy- length/32) bits of its SHA256 hash.
3. Add the checksum to the end of the random sequence.
4. Divide the sequence into sections of 11 bits.
5. Map each 11-bit value to a word from the predefined dictionary of 2048 words.
6. The mnemonic code is the sequence of words.

I can see this image

And I take this entropy

0c1e24e5917779d297e14d45f14e1a1a


If I follow the image, I create the checksum

printf 0c1e24e5917779d297e14d45f14e1a1a | xxd -r -p | sha256sum -b


result

76e57a90f93135e97ce700a9e79196ba46315d65e696d0a4518270a8de3e80e4


Then take 4 bits (0,5 byte => 1 char ) and append to my entropy with this result:

0c1e24e5917779d297e14d45f14e1a1a7


Now I have 132 bits And I have to split in 12 segments of 11 bits each

I try to convert in base 2

 echo "ibase=16; obase=2; 0C1E24E5917779D297E14D45F14E1A1A7" | bc

11000001111000100100111001011001000101110111011110011101001010010111111000010100110101000101111100010100111000011010000110100111


But the result is not correct, If I put that entropy in https://iancoleman.io/bip39/#entropy-notes I can see that result

00001100000 11110001001 00111001011 00100010111 01110111100 11101001010 01011111100 00101001101 01000101111 10001010011 10000110100 0011010


But I don't understand How can I obtain that

00001100000 = 96 = army

Your binary (which includes the 4 checksum bits 0111, or 7) has the leading null's removed.

(0000)1100000 11110001001 00111001011 00100010111 01110111100 11101001010 01011111100 00101001101 01000101111 10001010011 10000110100 00110100111

Which is identical to the binary (without checksum bits 0111) from the web tool:

00001100000 11110001001 00111001011 00100010111 01110111100 11101001010 01011111100 00101001101 01000101111 10001010011 10000110100 0011010....

(Note the missing checksum bits .... at the end)

• I don't understand sorry. My checksum is 7. 7 in binary is 111 echo "ibase=16; obase=2; 7" | bc. Commented Jan 29, 2019 at 14:05
• If I do echo "ibase=16; obase=2; 0C1E24E5917779D297E14D45F14E1A1A" | bcwithout seven I have 1100000111100010010011100101100100010111011101111001110100101001011111100001010011010100010111110001010011100001101000011010 Why I have to add 0000 to the beginning? Commented Jan 29, 2019 at 14:06
• Yes, 111 = 0111, the leading zeros are always clipped by your command line tool. But you need to maintain all leading bits, even if they are nulls, because we need exact multiples of 11 for the mnemonic key word. Commented Jan 29, 2019 at 14:07
• The 0 in 0C1E24E5917779D297E14D45F14E1A1A is 0000 bits, but these are clipped by the encoding tool. The tool preserves the value of the hex, because the leading null's do not contribute to the value, but we need a fixed-width binary encoding so we always have multiples of 11 bits for the words. Commented Jan 29, 2019 at 14:09
• If your entropy were 000E24E5917779D297E14D45F14E1A1A, it would clip the 12 leading 0 bits. Commented Jan 29, 2019 at 14:10