class BitBufferHelper {

    public static byte[] shiftBitsToLSB(byte[] inputBytes, int numBits) {
        int numBytes = inputBytes.length;
        int numBitstoShift = numBits % NetUtils.NUM_BITS_IN_A_BYTE;
        byte[] shiftedBytes = new byte[numBytes];
        int inputLsb = 0;
        int inputMsb = 0;

        if (numBitstoShift == 0) {
            return inputBytes;
        }

        for (int i = 1; i < numBytes; i++) {
            inputLsb = inputBytes[i - 1] & getLSBMask(NetUtils.NUM_BITS_IN_A_BYTE - numBitstoShift);
            inputLsb = inputLsb < 0 ? inputLsb + 256 : inputLsb;
            inputMsb = inputBytes[i] & getMSBMask(numBitstoShift);
            inputMsb = inputBytes[i] < 0 ? inputBytes[i] + 256 : inputBytes[i];
            shiftedBytes[i] = (byte) (inputLsb << numBitstoShift
                    | inputMsb >> NetUtils.NUM_BITS_IN_A_BYTE - numBitstoShift);
        }
        inputMsb = inputBytes[0] & getMSBMask(numBitstoShift);
        inputMsb = inputMsb < 0 ? inputMsb + 256 : inputMsb;
        shiftedBytes[0] = (byte) (inputMsb >> NetUtils.NUM_BITS_IN_A_BYTE - numBitstoShift);
        return shiftedBytes;
    }

    private  BitBufferHelper();

}