code: public char[] hash(char[] password, byte[] salt) {
      checkNotNull(password);
      checkArgument(password.length != 0);
      checkNotNull(salt);
      checkArgument(salt.length != 0);
  
      try {
        SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        SecretKey key =
            f.generateSecret(new PBEKeySpec(password, salt, ITERATIONS, DESIRED_KEY_LENGTH));
        return Base64.encodeBase64String(key.getEncoded()).toCharArray();
      } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
        throw new IllegalStateException("Could not hash the password of the user.", e);
      }
    }
docs: Hashes the password using pbkdf2 and the given salt.
  
  @param password the plain text password to hash.
  @param salt the salt for the password
  @return the hashed password