public static String encode(byte[] source, int off, int len, byte[] alphabet,
      boolean doPadding) {
    byte[] outBuff = encode(source, off, len, alphabet, Integer.MAX_VALUE);
    int outLen = outBuff.length;

    // If doPadding is false, set length to truncate '='
    // padding characters
    while (doPadding == false && outLen > 0) {
      if (outBuff[outLen - 1] != '=') {
        break;
      }
      outLen -= 1;
    }

    return new String(outBuff, 0, outLen);
  }
Encodes a byte array into Base64 notation.

@param source The data to convert
@param off Offset in array where conversion should begin
@param len Length of data to convert
@param alphabet is the encoding alphabet
@param doPadding is {@code true} to pad result with '=' chars
       if it does not fall on 3 byte boundaries
@since 1.4
android/android_framework/base/src/main/java/com/google/android/vending/licensing/util/Base64.java