<?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>Sat, 24 Jul 2010 04:15:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<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>
