public static byte[] decode(byte[] input, int offset, int len, int flags) {
    // Allocate space for the most data the input could represent.
    // (It could contain less if it contains whitespace, etc.)
    Decoder decoder = new Decoder(flags, new byte[len * 3 / 4]);

    if (!decoder.process(input, offset, len, true)) {
      throw new IllegalArgumentException("bad base-64");
    }

    // Maybe we got lucky and allocated exactly enough output space.
    if (decoder.op == decoder.output.length) {
      return decoder.output;
    }

    // Need to shorten the array, so allocate a new one of the
    // right size and copy.
    byte[] temp = new byte[decoder.op];
    System.arraycopy(decoder.output, 0, temp, 0, decoder.op);
    return temp;
  }
Decode the Base64-encoded data in input and return the data in a new byte array.

<p>The padding '=' characters at the end are considered optional, but if any are present, there
must be the correct number of them.

@param input the data to decode
@param offset the position within the input array at which to start
@param len the number of bytes of input to decode
@param flags controls certain features of the decoded output. Pass {@code DEFAULT} to decode
    standard Base64.
@throws IllegalArgumentException if the input contains incorrect padding
java_src/src/main/java/com/google/crypto/tink/subtle/Base64.java