protected byte[] Mask(int start, int length)
{
if (length < 1) return new byte[] { 0x00 };
int Bcnt = (int)Math.Ceiling((start + length) / 8.0);
byte[] output = new byte[Bcnt];
byte val = 0x80; // top bit;
int bcnt = start + length;
for (int i = 0; i < bcnt; i++) {
int B = i / 8;
int b = i % 8;
if (b == 0) val = 0x80;
else val >>= 1;
if (i >= start) output[B] |= val;
}
return output;
}