code: public static String convertSessionIdBytesToSessionId(byte[] pBytes, int sessionIdLength) {
          // int numBits = pBytes.length * 8;
          char[] chars = new char[sessionIdLength];
  
          int byteNum = 0;
          int bitNum = 0;
          int pos = 0;
          while (byteNum < pBytes.length && pos < sessionIdLength) {
              int val = 0;
  
              // Get from the byte
              if (bitNum < 3) {
                  val = (pBytes[byteNum] >> (2 - bitNum)) & 0x3f;
              }
              // Get from this byte and the next
              else {
                  val = pBytes[byteNum] << (6 - (8 - bitNum));
                  if (byteNum + 1 < pBytes.length) {
                      // LIDB2775.25 zOS int secondVal = pBytes[byteNum + 1] >> 8
                      // - (6 - (8 - bitNum)); /* @WS17270A */
                      int secondVal = (pBytes[byteNum + 1] & 0x000000ff) >> 8 - (6 - (8 - bitNum)); /*
                                                                                                     * cmdzos
                                                                                                     * 
                                                                                                     * @
                                                                                                     * WS17270A
                                                                                                     * and
                                                                                                     * 
                                                                                                     * @
                                                                                                     * MD16963C
                                                                                                     */
                      secondVal &= sSecondByteMasks[6 - (8 - bitNum)];
                      val |= secondVal;
                  }
                  val &= 0x3f;
              }
  
              // Assign the character
              chars[pos++] = sBitChars[val];
  
              // Increment to the next character
              bitNum += 6;
              if (bitNum >= 8) {
                  byteNum++;
                  bitNum -= 8;
              }
          }
  
          return new String(chars);
      }
docs: Method convertSessionIdBytesToSessionIdBase64 Converts the specified byte
  array to a String to be used for the session id. The conversion is
  performed breaking the byte array into groups of 6 bits, then taking each
  group (value 0-63) and converting to a character 'A'-'Z',
  'a'-'z','0'-'9',_,-.
  
  @param pBytes
  @return String