docs: private char[] encode(byte[] data) {
          char[] out = new char[((data.length + 2) / 3) * 4];
          char[] alphabet = SESSION_ID_ALPHABET;
          //
          // 3 bytes encode to 4 chars.  Output is always an even
          // multiple of 4 characters.
          //
          for (int i = 0, index = 0; i < data.length; i += 3, index += 4) {
              boolean quad = false;
              boolean trip = false;
  
              int val = (0xFF & (int) data[i]);
              val <<= 8;
              if ((i + 1) < data.length) {
                  val |= (0xFF & (int) data[i + 1]);
                  trip = true;
              }
              val <<= 8;
              if ((i + 2) < data.length) {
                  val |= (0xFF & (int) data[i + 2]);
                  quad = true;
              }
              out[index + 3] = alphabet[(quad ? (val & 0x3F) : 63)];
              val >>= 6;
              out[index + 2] = alphabet[(trip ? (val & 0x3F) : 63)];
              val >>= 6;
              out[index + 1] = alphabet[val & 0x3F];
              val >>= 6;
              out[index] = alphabet[val & 0x3F];
          }
          return out;
      }