code: public static String createAuthenticationHash(final String userName, final char[] password) {
          ByteArrayOutputStream bout = new ByteArrayOutputStream(userName.length() + 20 + password.length);
          try {
              bout.write(userName.getBytes(UTF_8_CHARSET));
              bout.write(":mongo:".getBytes(UTF_8_CHARSET));
              bout.write(new String(password).getBytes(UTF_8_CHARSET));
          } catch (IOException ioe) {
              throw new RuntimeException("impossible", ioe);
          }
          return hexMD5(bout.toByteArray());
      }
docs: Creates a hash of the given user name and password, which is the hex encoding of
  {@code MD5( <userName> + ":mongo:" + <password> )}.
  
  @param userName the user name
  @param password the password
  @return the hash as a string
  @mongodb.driver.manual ../meta-driver/latest/legacy/implement-authentication-in-driver/ Authentication