<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to store passwords safely with PHP and MySQL</title>
	<atom:link href="http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/</link>
	<description>Insights and Updates from a Tech Geek</description>
	<lastBuildDate>Tue, 31 Jan 2012 10:41:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Niek</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-326</link>
		<dc:creator>Niek</dc:creator>
		<pubDate>Tue, 31 Jan 2012 10:41:27 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-326</guid>
		<description>Great post. But something&#039;s not quite clear for me. When the user logs in, I can use &quot;$password = $_SERVER[&#039;PHP_AUTH_PW&#039;];&quot;, so the password is sent safely. 

But when I let my users register, I should do the same hash on the client side before sending using POST? So the hash will be sent as plaintext. So any attacker intercepting these packages can read the hash, create a custom request and use the hash to login under the user&#039;s name?</description>
		<content:encoded><![CDATA[<p>Great post. But something&#8217;s not quite clear for me. When the user logs in, I can use &#8220;$password = $_SERVER[&#8216;PHP_AUTH_PW&#8217;];&#8221;, so the password is sent&nbsp;safely. </p>
<p>But when I let my users register, I should do the same hash on the client side before sending using POST? So the hash will be sent as plaintext. So any attacker intercepting these packages can read the hash, create a custom request and use the hash to login under the user&#8217;s&nbsp;name?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-324</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Mon, 30 Jan 2012 09:51:36 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-324</guid>
		<description>Thanks very much! This seems to work quite well, but as somewhat of a newbie, it appears that the passwords are not unique, wherein the uniqueness comes from the username. The password uniqueness comes from the hashed match to the entered password, not to the password, as separate entries of the same password will create unique hashes for each password entry. With the number of iterations required to have a collision, is this deemed acceptable, or am I possibly doing something wrong, and each entered password should resolve as unique?</description>
		<content:encoded><![CDATA[<p>Thanks very much! This seems to work quite well, but as somewhat of a newbie, it appears that the passwords are not unique, wherein the uniqueness comes from the username. The password uniqueness comes from the hashed match to the entered password, not to the password, as separate entries of the same password will create unique hashes for each password entry. With the number of iterations required to have a collision, is this deemed acceptable, or am I possibly doing something wrong, and each entered password should resolve as&nbsp;unique?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JangoVimal</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-315</link>
		<dc:creator>JangoVimal</dc:creator>
		<pubDate>Wed, 11 Jan 2012 10:10:49 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-315</guid>
		<description>Notify user with an email which holds a link to create a new password. The link should also hold some encrypted character which can be active only for a certain time period may be 10 mins.</description>
		<content:encoded><![CDATA[<p>Notify user with an email which holds a link to create a new password. The link should also hold some encrypted character which can be active only for a certain time period may be 10&nbsp;mins.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-308</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 14 Dec 2011 16:09:34 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-308</guid>
		<description>Generate a new password.</description>
		<content:encoded><![CDATA[<p>Generate a new&nbsp;password.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doaa</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-303</link>
		<dc:creator>Doaa</dc:creator>
		<pubDate>Tue, 06 Dec 2011 03:18:10 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-303</guid>
		<description>I know that the hash cannot be reveresed. But what can be done in this case? An ideas?</description>
		<content:encoded><![CDATA[<p>I know that the hash cannot be reveresed. But what can be done in this case? An&nbsp;ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doaa</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-302</link>
		<dc:creator>Doaa</dc:creator>
		<pubDate>Tue, 06 Dec 2011 03:12:53 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-302</guid>
		<description>Thank you so much. I had one question, in my application I have a &quot;Forgot Password&quot; link, in which I send passwords to the users on their emails. If I stored the passwords hashed, how can I restore the original plain text to be sent?</description>
		<content:encoded><![CDATA[<p>Thank you so much. I had one question, in my application I have a &#8220;Forgot Password&#8221; link, in which I send passwords to the users on their emails. If I stored the passwords hashed, how can I restore the original plain text to be&nbsp;sent?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reyz</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-301</link>
		<dc:creator>Reyz</dc:creator>
		<pubDate>Mon, 05 Dec 2011 15:06:40 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-301</guid>
		<description>My code doesn&#039;t work.. :(</description>
		<content:encoded><![CDATA[<p>My code doesn&#8217;t work.. <img src='http://elbertf.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reyz</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-299</link>
		<dc:creator>Reyz</dc:creator>
		<pubDate>Mon, 05 Dec 2011 11:10:02 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-299</guid>
		<description>Hi.. Thank you for the article. Is it code fixed with the code in comment? I&#039;ll try it.

Once again, thank you.. :D</description>
		<content:encoded><![CDATA[<p>Hi.. Thank you for the article. Is it code fixed with the code in comment? I&#8217;ll try&nbsp;it.</p>
<p>Once again, thank you.. <img src='http://elbertf.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doaa</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-298</link>
		<dc:creator>Doaa</dc:creator>
		<pubDate>Mon, 05 Dec 2011 03:35:05 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-298</guid>
		<description>Thank you so much for this article. It&#039;s quite useful.</description>
		<content:encoded><![CDATA[<p>Thank you so much for this article. It&#8217;s quite&nbsp;useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ElbertF</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-297</link>
		<dc:creator>ElbertF</dc:creator>
		<pubDate>Sun, 04 Dec 2011 01:50:59 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-297</guid>
		<description>I&#039;m afraid storing the password in a cookie, hashed or not, is not safe. The password doesn&#039;t even need to be recovered for an attacker to take over the account if they know the hash.</description>
		<content:encoded><![CDATA[<p>I&#8217;m afraid storing the password in a cookie, hashed or not, is not safe. The password doesn&#8217;t even need to be recovered for an attacker to take over the account if they know the&nbsp;hash.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Champ Polestico</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-296</link>
		<dc:creator>Champ Polestico</dc:creator>
		<pubDate>Tue, 29 Nov 2011 14:33:37 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-296</guid>
		<description>Thanks for the concept!</description>
		<content:encoded><![CDATA[<p>Thanks for the&nbsp;concept!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tiago Roldão</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-295</link>
		<dc:creator>Tiago Roldão</dc:creator>
		<pubDate>Wed, 16 Nov 2011 23:01:14 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-295</guid>
		<description>If i put the md5($hash) in a cookie. Its possible to recover the password?

Just need to make sure.</description>
		<content:encoded><![CDATA[<p>If i put the md5($hash) in a cookie. Its possible to recover the&nbsp;password?</p>
<p>Just need to make&nbsp;sure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: deepz</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-281</link>
		<dc:creator>deepz</dc:creator>
		<pubDate>Mon, 05 Sep 2011 13:41:35 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-281</guid>
		<description>Your article has helped me alot. Thank you so much.</description>
		<content:encoded><![CDATA[<p>Your article has helped me alot. Thank you so&nbsp;much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-278</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Wed, 24 Aug 2011 08:53:30 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-278</guid>
		<description>LONG LIVE ROT13!

lol, I jest.. :)

Cool post.</description>
		<content:encoded><![CDATA[<p>LONG LIVE&nbsp;ROT13!</p>
<p>lol, I jest.. <img src='http://elbertf.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cool&nbsp;post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kremchik</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-245</link>
		<dc:creator>Kremchik</dc:creator>
		<pubDate>Wed, 27 Apr 2011 16:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-245</guid>
		<description>Thank you, very nice post, everything is perfectly clear!

Wish you write something about how to work with sessions in a way that a potential hacker could not log in even if he has got the DB and the sources both.</description>
		<content:encoded><![CDATA[<p>Thank you, very nice post, everything is perfectly&nbsp;clear!</p>
<p>Wish you write something about how to work with sessions in a way that a potential hacker could not log in even if he has got the DB and the sources&nbsp;both.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ElbertF</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-219</link>
		<dc:creator>ElbertF</dc:creator>
		<pubDate>Tue, 22 Mar 2011 22:03:44 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-219</guid>
		<description>Hashing SHA-256 over and over does not increase the chance of collisions AFAIK (as is the case with MD5), this is from what I&#039;ve read and tests I&#039;ve done myself. The added security comes from the time it takes to generate the hash, the same way Bcrypt does (you could of course just use Bcrypt but it&#039;s not always available on shared hosts). Eating up server resources is a &lt;em&gt;feature&lt;/em&gt; in this case. ;) &quot;Three strikes and your out&quot; is indeed useful but not if someone gets a hold of your database.</description>
		<content:encoded><![CDATA[<p>Hashing SHA-256 over and over does not increase the chance of collisions AFAIK (as is the case with MD5), this is from what I&#8217;ve read and tests I&#8217;ve done myself. The added security comes from the time it takes to generate the hash, the same way Bcrypt does (you could of course just use Bcrypt but it&#8217;s not always available on shared hosts). Eating up server resources is a <em>feature</em> in this case. <img src='http://elbertf.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  &#8220;Three strikes and your out&#8221; is indeed useful but not if someone gets a hold of your&nbsp;database.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: solo</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-215</link>
		<dc:creator>solo</dc:creator>
		<pubDate>Fri, 25 Feb 2011 14:13:44 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-215</guid>
		<description>Oh and obviously I&#039;m just talking about hashing 100000 times...</description>
		<content:encoded><![CDATA[<p>Oh and obviously I&#8217;m just talking about hashing 100000&nbsp;times&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: solo</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-211</link>
		<dc:creator>solo</dc:creator>
		<pubDate>Mon, 21 Feb 2011 20:17:13 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-211</guid>
		<description>I agree with @Andrew  - I think that this really provides no extra security, increases chance of collision, and eats up server resources.  Instead, I would just implement a &quot;3 strikes and your out&quot; method instead...</description>
		<content:encoded><![CDATA[<p>I agree with @Andrew  - I think that this really provides no extra security, increases chance of collision, and eats up server resources.  Instead, I would just implement a &#8220;3 strikes and your out&#8221; method&nbsp;instead&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Theodor</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-206</link>
		<dc:creator>Theodor</dc:creator>
		<pubDate>Thu, 06 Jan 2011 09:40:01 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-206</guid>
		<description>great posts thanks a lot ElbertF ;)

thanks too for wappalyzer !</description>
		<content:encoded><![CDATA[<p>great posts thanks a lot ElbertF <img src='http://elbertf.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>thanks too for wappalyzer&nbsp;!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-193</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Tue, 17 Aug 2010 15:53:54 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-193</guid>
		<description>Sorry but I thought that it is well documented that just doing this with MD5 -

$HashedPassword = $md5(md5($Password));

Increases the chance of collision dramatically?

So surely  when running this - 
for ( $i = 0; $i &lt; 100000; $i ++ )
{
$hash = hash(&#039;sha256&#039;, $hash);
}

you are increasing the chance of hash collision?

Im no expert and im unsure if MD5 and SHA256 work the same but I do know that it is a big NO NO to rehash a hash as it increases chances of collision.</description>
		<content:encoded><![CDATA[<p>Sorry but I thought that it is well documented that just doing this with MD5&nbsp;-</p>
<p>$HashedPassword =&nbsp;$md5(md5($Password));</p>
<p>Increases the chance of collision&nbsp;dramatically?</p>
<p>So surely  when running this -<br />
for ( $i = 0; $i &lt; 100000; $i ++ )<br />
{<br />
$hash = hash(&#039;sha256&#039;, $hash);<br />&nbsp;}</p>
<p>you are increasing the chance of hash&nbsp;collision?</p>
<p>Im no expert and im unsure if MD5 and SHA256 work the same but I do know that it is a big NO NO to rehash a hash as it increases chances of&nbsp;collision.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ElbertF</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-70</link>
		<dc:creator>ElbertF</dc:creator>
		<pubDate>Mon, 01 Mar 2010 06:19:51 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-70</guid>
		<description>Fixed it, thanks.</description>
		<content:encoded><![CDATA[<p>Fixed it,&nbsp;thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: garyamort</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-68</link>
		<dc:creator>garyamort</dc:creator>
		<pubDate>Fri, 19 Feb 2010 02:11:44 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-68</guid>
		<description>The above is good for a general rule of thumb, however one must always be ready to be flexible when needed.&lt;br&gt;&lt;br&gt;For one thing, not all websites are a vacumn, thus whatever mechanism you may include the OPTION of validating at least initially to a different format.  For example, many systems do store MD5 passwords, and it is a simple matter to export them when migrating.  So for a special use case[migration of users], you would want to allow the user to sign in using their old password, and then immediately rehash and save it.&lt;br&gt;&lt;br&gt;Additionally, you may be working on a web service for other users, in which case there should be an option to export data in a manner which allows people to use that data on their own server.  Locking people into your system is rude and obnoxious, there should always be a migration option.&lt;br&gt;&lt;br&gt;Lastly, there are indeed times when you will need to allow a site owner to log on as someone else.  Customer service is key.  In those cases, explaining how much more secure the password system is is useless, you must give them a way to log on.  Either store the password in some manner that they can look it up, or provide functionality to allow an admin to &quot;impersonate&quot; a user.</description>
		<content:encoded><![CDATA[<p>The above is good for a general rule of thumb, however one must always be ready to be flexible when&nbsp;needed.</p>
<p>For one thing, not all websites are a vacumn, thus whatever mechanism you may include the OPTION of validating at least initially to a different format.  For example, many systems do store MD5 passwords, and it is a simple matter to export them when migrating.  So for a special use case[migration of users], you would want to allow the user to sign in using their old password, and then immediately rehash and save&nbsp;it.</p>
<p>Additionally, you may be working on a web service for other users, in which case there should be an option to export data in a manner which allows people to use that data on their own server.  Locking people into your system is rude and obnoxious, there should always be a migration&nbsp;option.</p>
<p>Lastly, there are indeed times when you will need to allow a site owner to log on as someone else.  Customer service is key.  In those cases, explaining how much more secure the password system is is useless, you must give them a way to log on.  Either store the password in some manner that they can look it up, or provide functionality to allow an admin to &#8220;impersonate&#8221; a&nbsp;user.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Name</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-67</link>
		<dc:creator>Name</dc:creator>
		<pubDate>Thu, 18 Feb 2010 09:05:23 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-67</guid>
		<description>&lt;------- CORRECTION TO THE ABOVE ---------&gt;&lt;br&gt;I had a typo in there . . . &lt;br&gt;&lt;br&gt;Doesn&#039;t work as written. Need to concatenate the user&#039;s input password with the salt again after getting it from the login form . . .&lt;br&gt;&lt;br&gt;. . . . $r = mysql_fetch_assoc(mysql_query($sql));&lt;br&gt;&lt;br&gt;// The first 64 characters of the hash is the salt&lt;br&gt;$salt = substr($r[&#039;hash&#039;], 0, 64);&lt;br&gt;&lt;br&gt;$hash = $salt . $password; &lt;------------ (TYPO FIXED) INSERT THIS LINE HERE (IN 2ND CODE SECTION)&lt;br&gt;&lt;br&gt;// Hash the password as we did before&lt;br&gt;for ( $i = 0; $i &lt; 100000; $i ++ )&lt;br&gt;{&lt;br&gt;$hash = hash(&#039;sha256&#039;, $hash);&lt;br&gt;} . . . . // ETCETERA</description>
		<content:encoded><![CDATA[<p>&lt;&#8212;&#8212;&#8212;- CORRECTION TO THE ABOVE &#8212;&#8212;&#8212;&#8212;-&gt;<br />I had a typo in there . .&nbsp;. </p>
<p>Doesn&#39;t work as written. Need to concatenate the user&#39;s input password with the salt again after getting it from the login form . .&nbsp;.</p>
<p>&#8230; . $r =&nbsp;mysql_fetch_assoc(mysql_query($sql));</p>
<p>// The first 64 characters of the hash is the salt<br />$salt = substr($r[&#39;hash&#39;], 0,&nbsp;64);</p>
<p>$hash = $salt . $password; &lt;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; (TYPO FIXED) INSERT THIS LINE HERE (IN 2ND CODE&nbsp;SECTION)</p>
<p>// Hash the password as we did before<br />for ( $i = 0; $i &lt; 100000; $i ++ )<br />{<br />$hash = hash(&#39;sha256&#39;, $hash);<br />} &#8230; . //&nbsp;ETCETERA</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Name</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-66</link>
		<dc:creator>Name</dc:creator>
		<pubDate>Thu, 18 Feb 2010 09:02:49 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-66</guid>
		<description>Doesn&#039;t work as written. Need to concatenate the user&#039;s input password with the salt again after getting it from the login form . . .&lt;br&gt;&lt;br&gt;. . . .  $r = mysql_fetch_assoc(mysql_query($sql));&lt;br&gt; &lt;br&gt;// The first 64 characters of the hash is the salt&lt;br&gt;$salt = substr($r[&#039;hash&#039;], 0, 64);&lt;br&gt;&lt;br&gt;$hash = $hash . $password;   &lt;------------ INSERT THIS LINE HERE (IN 2ND CODE SECTION)&lt;br&gt;&lt;br&gt;// Hash the password as we did before&lt;br&gt;for ( $i = 0; $i &lt; 100000; $i ++ )&lt;br&gt;{&lt;br&gt;    $hash = hash(&#039;sha256&#039;, $hash);&lt;br&gt;}  . . . . // ETCETERA</description>
		<content:encoded><![CDATA[<p>Doesn&#39;t work as written. Need to concatenate the user&#39;s input password with the salt again after getting it from the login form . .&nbsp;.</p>
<p>&#8230; .  $r =&nbsp;mysql_fetch_assoc(mysql_query($sql));</p>
<p>// The first 64 characters of the hash is the salt<br />$salt = substr($r[&#39;hash&#39;], 0,&nbsp;64);</p>
<p>$hash = $hash . $password;   &lt;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; INSERT THIS LINE HERE (IN 2ND CODE&nbsp;SECTION)</p>
<p>// Hash the password as we did before<br />for ( $i = 0; $i &lt; 100000; $i ++ )<br />{<br />    $hash = hash(&#39;sha256&#39;, $hash);<br />}  &#8230; . //&nbsp;ETCETERA</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ElbertF</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-65</link>
		<dc:creator>ElbertF</dc:creator>
		<pubDate>Tue, 16 Feb 2010 01:28:16 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-65</guid>
		<description>Because a potential hacker would be able to brute-force the password on another machine without using sleep(). You need the algorithm to be slow.</description>
		<content:encoded><![CDATA[<p>Because a potential hacker would be able to brute-force the password on another machine without using sleep(). You need the algorithm to be&nbsp;slow.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PA</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-64</link>
		<dc:creator>PA</dc:creator>
		<pubDate>Mon, 15 Feb 2010 17:16:52 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-64</guid>
		<description>Why not use the sleep() function instead of hashing multiple times ?&lt;br&gt;&lt;br&gt;Then :&lt;br&gt;- you wouldn&#039;t increase the chance of collisions&lt;br&gt;- you wouldn&#039;t increase the server load</description>
		<content:encoded><![CDATA[<p>Why not use the sleep() function instead of hashing multiple times&nbsp;?</p>
<p>Then :<br />- you wouldn&#39;t increase the chance of collisions<br />- you wouldn&#39;t increase the server&nbsp;load</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ElbertF</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-63</link>
		<dc:creator>ElbertF</dc:creator>
		<pubDate>Fri, 12 Feb 2010 01:41:12 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-63</guid>
		<description>Yes that&#039;s true. If you&#039;re simply after the admin password and know the full hash and algorithm the random salt won&#039;t make a difference. The only thing that can help you is a strong password (you could store the hash on a different server).&lt;br&gt;&lt;br&gt;Hashing multiple times may increase the chance of collisions slightly but I don&#039;t think it matters to much in this case. You&#039;d still have to perform the hash a 100,000 times which slows brute forcing down significantly. If computers get faster you can just hash all the passwords some more.</description>
		<content:encoded><![CDATA[<p>Yes that&#39;s true. If you&#39;re simply after the admin password and know the full hash and algorithm the random salt won&#39;t make a difference. The only thing that can help you is a strong password (you could store the hash on a different&nbsp;server).</p>
<p>Hashing multiple times may increase the chance of collisions slightly but I don&#39;t think it matters to much in this case. You&#39;d still have to perform the hash a 100,000 times which slows brute forcing down significantly. If computers get faster you can just hash all the passwords some&nbsp;more.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tijn</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-62</link>
		<dc:creator>Tijn</dc:creator>
		<pubDate>Thu, 11 Feb 2010 18:33:02 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-62</guid>
		<description>I don&#039;t fully understand what the random salt is for. A single site-wide salt is bad because &quot;someone with access to your code can find the salt&quot;, but I don&#039;t see how prefixing the hashed string with a random salt makes any difference.&lt;br&gt;&lt;br&gt;If I have access to the database, I could just look at the first 64 characters and create a new rainbow table. The only real difference is that it will take more time to &quot;decode&quot; the password of ALL users, but when you&#039;re looking at a single password, this method doesn&#039;t seem more secure.&lt;br&gt;&lt;br&gt;Also, I&#039;m not a security expert :), but is it really better to hash something multiple times?</description>
		<content:encoded><![CDATA[<p>I don&#39;t fully understand what the random salt is for. A single site-wide salt is bad because &#8220;someone with access to your code can find the salt&#8221;, but I don&#39;t see how prefixing the hashed string with a random salt makes any&nbsp;difference.</p>
<p>If I have access to the database, I could just look at the first 64 characters and create a new rainbow table. The only real difference is that it will take more time to &#8220;decode&#8221; the password of ALL users, but when you&#39;re looking at a single password, this method doesn&#39;t seem more&nbsp;secure.</p>
<p>Also, I&#39;m not a security expert <img src='http://elbertf.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , but is it really better to hash something multiple&nbsp;times?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Cinel</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-60</link>
		<dc:creator>Tim Cinel</dc:creator>
		<pubDate>Mon, 01 Feb 2010 02:21:17 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-60</guid>
		<description>That&#039;s a big salt. I was thinking it would be better to have a secret component in the salt but upon further thought it wouldn&#039;t help.&lt;br&gt;Thanks for the article ^^ Death to plaintext password storage!</description>
		<content:encoded><![CDATA[<p>That&#39;s a big salt. I was thinking it would be better to have a secret component in the salt but upon further thought it wouldn&#39;t help.<br />Thanks for the article ^^ Death to plaintext password&nbsp;storage!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ElbertF</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-59</link>
		<dc:creator>ElbertF</dc:creator>
		<pubDate>Mon, 01 Feb 2010 01:37:46 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-59</guid>
		<description>Thanks Ramon! Actually it&#039;s the opposite, strtolower() makes sure the login to is case insensitive (in the SQL query case doesn&#039;t matter).</description>
		<content:encoded><![CDATA[<p>Thanks Ramon! Actually it&#39;s the opposite, strtolower() makes sure the login to is case insensitive (in the SQL query case doesn&#39;t&nbsp;matter).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramon Fincken</title>
		<link>http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/comment-page-1/#comment-58</link>
		<dc:creator>Ramon Fincken</dc:creator>
		<pubDate>Sun, 31 Jan 2010 15:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://ElbertF.com/?p=447#comment-58</guid>
		<description>I like your article ! &lt;br&gt;&lt;br&gt;However you presume usernames are fixed and TheName is another user as thename &gt; strtolower($username)</description>
		<content:encoded><![CDATA[<p>I like your article&nbsp;! </p>
<p>However you presume usernames are fixed and TheName is another user as thename &gt;&nbsp;strtolower($username)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

