code: public static ByteBuffer encode(byte[] input) {
  		int pos = input.length + input.length / 3;
  		if (pos < 64) pos = 64;
  		byte[] out = new byte[pos];
  		pos = 0;
  		int lineCount = 0;
  		for (int i = 0; i < input.length; ++i) {
  			byte b = input[i];
  			if ((b >= 33 && b <= 60) || (b >= 62 && b <= 126) || ((b == 9 || b == 32) && lineCount < 73 && i < input.length - 1)) {
  				if (lineCount == 73) {
  					if (pos >= out.length - 4)
  						out = increaseBuffer(out, pos);
  					out[pos++] = '=';
  					out[pos++] = '\r';
  					out[pos++] = '\n';
  					lineCount = 0;
  				} else
  					if (pos >= out.length - 1)
  						out = increaseBuffer(out, pos);
  				out[pos++] = b;
  				lineCount++;
  				continue;
  			}
  			// need to encode
  			if (lineCount >= 73 - (i < input.length - 1 ? 1 : 0)) {
  				if (pos >= out.length - 7)
  					out = increaseBuffer(out, pos);
  				out[pos++] = '=';
  				out[pos++] = '\r';
  				out[pos++] = '\n';
  				lineCount = 0;
  			}
  			if (pos >= out.length - 3)
  				out = increaseBuffer(out, pos);
  			out[pos++] = '=';
  			out[pos++] = (byte)StringUtil.encodeHexaDigit((b & 0xF0) >> 4);
  			out[pos++] = (byte)StringUtil.encodeHexaDigit(b & 0xF);
  			lineCount += 3;
  		}
  		return ByteBuffer.wrap(out, 0, pos);
  	}
docs: Encode the given input.