title: Correctly using crypt() with SHA512 in PHP
body: <p>All the examples online show the use of crypt like this:</p>
  <pre><code>$pass = crypt('something','$6$rounds=5000$anexamplestringforsalt$');
  </code></pre>
  <p>But everyone says that you are not supposed to define the rounds or the salt.</p>
  <p>So how should I use it?</p>
  <p>Also I am having a problem: when I run the code above, it only runs 50 rounds instead of 5000 rounds as if the system is stopping it.</p>
  <p>Any help will be greatly appreciated.</p>
  <p><strong>//- Solution -//</strong></p>
  <p>I have found some of these to be useful:</p>
  <p><strong>For generating Salt:</strong></p>
  <p>Here is a random way of generating salt</p>
  <pre><code>$randomString = random_bytes(32);
  </code></pre>
  <p>Base 64 encode to ensure that some characters will not cause problems for crypt</p>
  <pre><code>$salt = base64_encode($randomString);
  </code></pre>
  <p><strong>For Hashing:</strong></p>
  <pre><code>$hashed = crypt($passwordInput, '$6$'.$salt);
  </code></pre>
  <p><strong>To Confirm:</strong></p>
  <pre><code>if (crypt($passwordInput, $hashed) == $hashed) { 
    // Valid action
  } else { 
    // Invalid action
  }
  </code></pre>
  <p>** Special Thanks to @<strong>lathspell</strong> for help with arriving at above solution **</p>