private static int decode0(char[] ibuf, byte[] obuf, int wp) {
        int outlen = 3;

        if (ibuf[3] == '=') {
            outlen = 2;
        }
        if (ibuf[2] == '=') {
            outlen = 1;
        }

        int b0 = STANDARD_DECODE_TABLE[ibuf[0]];
        int b1 = STANDARD_DECODE_TABLE[ibuf[1]];
        int b2 = STANDARD_DECODE_TABLE[ibuf[2]];
        int b3 = STANDARD_DECODE_TABLE[ibuf[3]];

        switch (outlen) {

            case 1:
                obuf[wp] = ((byte) (b0 << 2 & 0xFC | b1 >> 4 & 0x3));
                return 1;
            case 2:
                obuf[(wp++)] = ((byte) (b0 << 2 & 0xFC | b1 >> 4 & 0x3));
                obuf[wp] = ((byte) (b1 << 4 & 0xF0 | b2 >> 2 & 0xF));
                return 2;
            case 3:
                obuf[(wp++)] = ((byte) (b0 << 2 & 0xFC | b1 >> 4 & 0x3));
                obuf[(wp++)] = ((byte) (b1 << 4 & 0xF0 | b2 >> 2 & 0xF));
                obuf[wp] = ((byte) (b2 << 6 & 0xC0 | b3 & 0x3F));
                return 3;
        }

        throw new RuntimeException("Base64 Internal Error");
    }