I am generating a SHA1 digest that I want to use for some values.

I want to take the digest that is generated at extact a given number

of bits, in sequence.

SHA1 generates 160 bits.

I would like to partition that 160 bits into an array storing the

value of those bits

for instance (in short form using only 10 bits grabbing 2 at a time)

lets say I have:

1010010101

and I am grabbing pairs I need (from least to most):

@somearray

$somearray[0] = 1 (01)

$somearray[1] = 1 (01)

$somearray[2] = 1 (01)

$somearray[3] = 2 (10)

$somearray[4] = 2 (10)

I I tried using vec (going back to the full 160 bits) but it fails

miserably. Here a sample

Using vec($digest,$loop*8,

(Grabbing 8 bits)

I would get

0101010101

1101011010

100101001010101101

010110110101011101

....

The lengths would be wrong (doing an unpack "b*" on the array that was

holding the result. Sometimes I would get 8, other 16 and the number

even changes running the same data!)

I even tried using the Binary::Vector with a Chunk_Read and got

similar results.

This should be this hard to just extract X bits from a Y*X offset

where Y is the loop iteration.

What am I missing?