title: How can I decrypt a password hash in PHP?
body: <p>I need to decrypt a password. The password is encrypted with <code>password_hash</code> function.</p>
  
  <pre><code>$password = 'examplepassword';
  $crypted = password_hash($password, PASSWORD_DEFAULT);
  </code></pre>
  
  <p>Now, let's assume that <code>$crypted</code> is stored in a database (there's a "users" table, with usernames, passwords, etc) and I need to do a login: I have to see if the password entered by the user matches the encrypted password stored in the database.</p>
  
  <p>This is the sql code...</p>
  
  <pre><code>$sql_script = 'select * from USERS where username="'.$username.'" and password="'.$inputpassword.'"';
  </code></pre>
  
  <p>...but <code>$inputpassword</code> is not encrypted, so it's not equal to what is stored in the password field of the table users...</p>
  
  <p>So, there's a function to decrypt after the use of <code>password_hash</code>? Or should I change my encrypt method? Or what else?</p>