docs: public static byte[] encode(final byte[] source, final int off, final int len) {
          if (source == null) {
              throw new NullPointerException("Cannot serialize a null array.");
          }
  
          if (off < 0) {
              throw new IllegalArgumentException("Cannot have negative offset: " + off);
          }
  
          if (len < 0) {
              throw new IllegalArgumentException("Cannot have negative length: " + len);
          }
  
          if (off + len > source.length) {
              throw new IllegalArgumentException(String.format(
                      "Cannot have offset of %d and length of %d with array of length %d",
                      off,
                      len,
                      source.length));
          }
  
          if (len == 0) {
              return new byte[0];
          }
  
          //int    len43   = len * 4 / 3;
          //byte[] outBuff = new byte[   ( len43 )                      // Main 4:3
          //                           + ( (len % 3) > 0 ? 4 : 0 )      // Account for padding
          //                           + (breakLines ? ( len43 / MAX_LINE_LENGTH ) : 0) ]; // New lines
          // Try to determine more precisely how big the array needs to be.
          // If we get it right, we don't have to do an array copy, and
          // we save a bunch of memory.
          int blocks = len / 3;
          int extra = len % 3;
          int bufLen = blocks * 4 + (extra > 0 ? extra + 1 : 0); // Bytes needed for actual encoding
          byte[] dest = new byte[bufLen];
  
          int srcPos = 0;
          int destPos = 0;
          final int len2 = len - 2;
          for (; srcPos < len2; srcPos += 3) {
              destPos += encode3to4(source, srcPos + off, 3, dest, destPos);
          }
  
          if (srcPos < len) {
              encode3to4(source, srcPos + off, len - srcPos, dest, destPos);
          }
  
          return dest;
      }