Ideal way to encrypt user passwords
<p>I initially used MD5 when i first started out coding to hash user passwords.</p>

<pre><code> $password1 = md5($password);
</code></pre>

<p>After reading countless of pages with different opinions, what shall i be using?  <code>crypt</code>,<code>SHA1</code>,<code>SHA256</code>... here is an example of how i revised code by using SHA1 and static salting.</p>

<pre><code>$salt = '324912343223942833294328432392';
$passwordarray = str_split($password,2);
$password1 = sha1($passwordarray[0].$salt.$passwordarray[1]);
//insert $password1 into database
</code></pre>

<p>when logging in and checking password..</p>

<pre><code>$salt = '324912343223942833294328432392';

    $passwordarray = str_split($password,2);
    $dbpasswordarray = str_split($dbpasswordarray,2);

    $password = sha1($passwordarray[0].$salt.$passwordarray[1]);
    $dbpassword = sha1($dbpasswordarray[0].$salt.$dbpasswordarray[1]);

               if ($username==$dbusername&amp;&amp;md5($password3)==$dbpassword)
               {    
</code></pre>

<p>What shall i do to improve/change this code and make it more secure? .. can i have an example..  Shall i do dynamic salting and add a unique salt to each user in the database?</p>
