title: Is there any PHP Equivalent of the JAVA SecretKeyFactory to make a login system?
body: <p>(It's my first post here.)</p>
  
  <p>I'm programming a minecraft server website and I want to put a login system.
  My minecraft server (<strong>BungeeCord</strong>) is using "<strong>BungeeAuth</strong>" to ask players to set a password to their accounts.</p>
  
  <p>The BungeeAuth's password is stored in my Mysql server with two main colomns : "<em>playername</em>" and "<em>password</em>".</p>
  
  <p>I want to be able to log in with this password on my website.</p>
  
  <p>The password is hashed strangly. I decided to decompile "BungeeAuth" to see how it works.</p>
  
  <p>This is the librairies :</p>
  
  <pre><code>import java.math.BigInteger;
  import java.security.NoSuchAlgorithmException;
  import java.security.SecureRandom;
  import java.security.spec.InvalidKeySpecException;
  import javax.crypto.SecretKey;
  import javax.crypto.SecretKeyFactory;
  import javax.crypto.spec.PBEKeySpec;
  </code></pre>
  
  <p>This is the code :</p>
  
  <pre><code>public boolean validatePassword(String originalPassword, String storedPassword)
          throws NoSuchAlgorithmException, InvalidKeySpecException {
      String parts[] = storedPassword.split(":");
      int iterations = Integer.parseInt(parts[0]);
      byte salt[] = fromHex(parts[1]);
      byte hash[] = fromHex(parts[2]);
      PBEKeySpec spec = new PBEKeySpec(originalPassword.toCharArray(), salt, iterations, hash.length * 8);
      SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
      byte testHash[] = skf.generateSecret(spec).getEncoded();
      int diff = hash.length ^ testHash.length;
      for (int i = 0; i &lt; hash.length &amp;&amp; i &lt; testHash.length; i++) {
          diff |= hash[i] ^ testHash[i];
      }
  
      return diff == 0;
  }
  
  private static byte[] fromHex(String hex)
          throws NoSuchAlgorithmException {
      byte bytes[] = new byte[hex.length() / 2];
      for (int i = 0; i &lt; bytes.length; i++) {
          bytes[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16);
      }
  
      return bytes;
  }
  </code></pre>
  
  <p>I understanded that the salt is random and the password is crypted in <strong>SHA1</strong> (<em>PBKDF2WithHmacSHA1</em>).</p>
  
  <p>Is there any function in PHP to do the same ?
  I've tried <em>hash_hmac('sha1', ..., $salt)</em> but it seems to be different.</p>