<?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: PHP Password Security</title>
	<atom:link href="http://www.richardlord.net/blog/php-password-security/feed" rel="self" type="application/rss+xml" />
	<link>http://www.richardlord.net/blog/php-password-security</link>
	<description>Actionscript/Flex, PHP and Java developer</description>
	<lastBuildDate>Sat, 24 Jul 2010 00:46:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: ed</title>
		<link>http://www.richardlord.net/blog/php-password-security/comment-page-1#comment-38254</link>
		<dc:creator>ed</dc:creator>
		<pubDate>Fri, 16 Jul 2010 01:01:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/php-password-security/#comment-38254</guid>
		<description>wouldnt it be better to do

return $salt . hash($algo, $pass . $salt . $pass)

instead of just $salt . hash($algo, $salt . $pass)?

that way the attacker won&#039;t even figure out were the (2nd) salt is?</description>
		<content:encoded><![CDATA[<p>wouldnt it be better to do</p>
<p>return $salt . hash($algo, $pass . $salt . $pass)</p>
<p>instead of just $salt . hash($algo, $salt . $pass)?</p>
<p>that way the attacker won&#8217;t even figure out were the (2nd) salt is?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Php database password</title>
		<link>http://www.richardlord.net/blog/php-password-security/comment-page-1#comment-36910</link>
		<dc:creator>Php database password</dc:creator>
		<pubDate>Sun, 13 Jun 2010 02:38:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/php-password-security/#comment-36910</guid>
		<description>A question.   I have seen lots of questions but no real  answers to this one for php security.

I hate placing the connection information for the mysql database connection in any form of plain text, even in my code.

It seems like there &quot;ought&quot; to be a way to use hashing etc. to create a more secure method, perhaps pulling the connection info from a file with the file only storing the hashed key, etc. and pulling the salt from a completely separate locale...

Thoughts?</description>
		<content:encoded><![CDATA[<p>A question.   I have seen lots of questions but no real  answers to this one for php security.</p>
<p>I hate placing the connection information for the mysql database connection in any form of plain text, even in my code.</p>
<p>It seems like there &#8220;ought&#8221; to be a way to use hashing etc. to create a more secure method, perhaps pulling the connection info from a file with the file only storing the hashed key, etc. and pulling the salt from a completely separate locale&#8230;</p>
<p>Thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anders Törnkvist</title>
		<link>http://www.richardlord.net/blog/php-password-security/comment-page-1#comment-36596</link>
		<dc:creator>Anders Törnkvist</dc:creator>
		<pubDate>Tue, 01 Jun 2010 23:49:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/php-password-security/#comment-36596</guid>
		<description>In addition, it is important to remember that every login request preferably should be over SSL or otherwise the password must not be transmitted in clear text (for example, instead of using SSL the password could be hashed with Javascript by the client using the salt stored in the DB on the server (the server supplies the salt on AJAX request) and then this hash should be hashed (using the same or another hash method, the salt should this time be randomized by the server for every login attempt) before transmitted to the server).</description>
		<content:encoded><![CDATA[<p>In addition, it is important to remember that every login request preferably should be over SSL or otherwise the password must not be transmitted in clear text (for example, instead of using SSL the password could be hashed with Javascript by the client using the salt stored in the DB on the server (the server supplies the salt on AJAX request) and then this hash should be hashed (using the same or another hash method, the salt should this time be randomized by the server for every login attempt) before transmitted to the server).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.richardlord.net/blog/php-password-security/comment-page-1#comment-36075</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 18 May 2010 19:17:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/php-password-security/#comment-36075</guid>
		<description>Ah thanks a lot, i did not see that the salt is added to the hash again. Excellent article!</description>
		<content:encoded><![CDATA[<p>Ah thanks a lot, i did not see that the salt is added to the hash again. Excellent article!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard</title>
		<link>http://www.richardlord.net/blog/php-password-security/comment-page-1#comment-35983</link>
		<dc:creator>Richard</dc:creator>
		<pubDate>Sun, 16 May 2010 18:13:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/php-password-security/#comment-35983</guid>
		<description>Peter, you store the hash and the random string in the database, then use the same random string when comparing. I concatenate the random string with the hash when saving it, then split them apart again when comparing.</description>
		<content:encoded><![CDATA[<p>Peter, you store the hash and the random string in the database, then use the same random string when comparing. I concatenate the random string with the hash when saving it, then split them apart again when comparing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.richardlord.net/blog/php-password-security/comment-page-1#comment-35976</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Sun, 16 May 2010 15:28:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/php-password-security/#comment-35976</guid>
		<description>Sorry, i dont get it. You mix a random string with the password, hash them and when you try to compare the password again, you generate another random value and hash it with the password?

If your random strings are not equal (which should be the case in most of the times) how do you get the same hash value again?</description>
		<content:encoded><![CDATA[<p>Sorry, i dont get it. You mix a random string with the password, hash them and when you try to compare the password again, you generate another random value and hash it with the password?</p>
<p>If your random strings are not equal (which should be the case in most of the times) how do you get the same hash value again?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: max</title>
		<link>http://www.richardlord.net/blog/php-password-security/comment-page-1#comment-35722</link>
		<dc:creator>max</dc:creator>
		<pubDate>Sun, 09 May 2010 16:05:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/php-password-security/#comment-35722</guid>
		<description>I totally agree with you about functional speed. The problem is all these algorithms have been developed/designed for speed and there is always gonna be a faster computer coming out next year, not to discount the mainframes of today. Personally I like exponential algorithms which can really tick down CPU and also involving various types available which is problematic if you are depending on what only comes with the package. Ideally it means a separate executable which PHP calls on to hash and then having an event to signal authenticity not to mention the timeout. If the result is as randomized as possible, and the executable is safe from reverse engineering. That&#039;s basically all you can do. It does mean though that, commercially it&#039;s not viable to release without compromising it&#039;s security to possible disassembly. Best developed in-house, kept in-house and hush, don&#039;t tell anyone.</description>
		<content:encoded><![CDATA[<p>I totally agree with you about functional speed. The problem is all these algorithms have been developed/designed for speed and there is always gonna be a faster computer coming out next year, not to discount the mainframes of today. Personally I like exponential algorithms which can really tick down CPU and also involving various types available which is problematic if you are depending on what only comes with the package. Ideally it means a separate executable which PHP calls on to hash and then having an event to signal authenticity not to mention the timeout. If the result is as randomized as possible, and the executable is safe from reverse engineering. That&#8217;s basically all you can do. It does mean though that, commercially it&#8217;s not viable to release without compromising it&#8217;s security to possible disassembly. Best developed in-house, kept in-house and hush, don&#8217;t tell anyone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard</title>
		<link>http://www.richardlord.net/blog/php-password-security/comment-page-1#comment-35078</link>
		<dc:creator>Richard</dc:creator>
		<pubDate>Tue, 20 Apr 2010 17:10:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/php-password-security/#comment-35078</guid>
		<description>I only have to make one request to the database to check the user&#039;s login. The salt is returned as part of that request, along with the salted &amp; hashed password.

I&#039;m not clear of the value of your convoluted algorithm over simply using a good, robust hash algorithm.</description>
		<content:encoded><![CDATA[<p>I only have to make one request to the database to check the user&#8217;s login. The salt is returned as part of that request, along with the salted &#038; hashed password.</p>
<p>I&#8217;m not clear of the value of your convoluted algorithm over simply using a good, robust hash algorithm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ariel</title>
		<link>http://www.richardlord.net/blog/php-password-security/comment-page-1#comment-34790</link>
		<dc:creator>Ariel</dc:creator>
		<pubDate>Sun, 11 Apr 2010 06:37:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/php-password-security/#comment-34790</guid>
		<description>The great thing is in your code is to create a second variable to hinder decryption.

If I understand your code, you will need to make one request to the database to get  the Salt before comparing the password.

On my system I use the following idea.
1 - make only a single request to the database
2 - use two variables - (password  and user)
3 - treat the password with different hash to minimize the collisions
5 - encourage the use of non-alphanumeric characters.
4 - Create a final string much larger than the hash to became the original data impossible to find.

some thing like this:

&lt;code&gt;

function goodLuckToFoundThePass($user, $password){
    $sha = md5($user).sha1(&#039;%&amp;some^&amp;name$/here&#039;.$password, &#039;a&#039;).md5(strrev($user));
	$half = round(strlen($sha)/2);
	$sha1 = substr($sha, 0,$half);
	$sha2 = substr($sha, $half);
	$sha3 = $sha1 . &#039;the best way to create a secure password is making final string much larger than the hash to became the original data IMPOSSIBLE to find&#039; . $sha2;
	$NewPassword = md5($sha3.$sha1, 1).md5($sha3.$sha2, 1);
	return $NewPassword;
}

&lt;/code&gt;
Collisions? Maybe. 1 for pow(2,512);
but the ideia here is protect your users.

Ps: Sorry my English.</description>
		<content:encoded><![CDATA[<p>The great thing is in your code is to create a second variable to hinder decryption.</p>
<p>If I understand your code, you will need to make one request to the database to get  the Salt before comparing the password.</p>
<p>On my system I use the following idea.<br />
1 &#8211; make only a single request to the database<br />
2 &#8211; use two variables &#8211; (password  and user)<br />
3 &#8211; treat the password with different hash to minimize the collisions<br />
5 &#8211; encourage the use of non-alphanumeric characters.<br />
4 &#8211; Create a final string much larger than the hash to became the original data impossible to find.</p>
<p>some thing like this:</p>
<p><code></p>
<p>function goodLuckToFoundThePass($user, $password){<br />
    $sha = md5($user).sha1('%&amp;some^&amp;name$/here'.$password, 'a').md5(strrev($user));<br />
	$half = round(strlen($sha)/2);<br />
	$sha1 = substr($sha, 0,$half);<br />
	$sha2 = substr($sha, $half);<br />
	$sha3 = $sha1 . 'the best way to create a secure password is making final string much larger than the hash to became the original data IMPOSSIBLE to find' . $sha2;<br />
	$NewPassword = md5($sha3.$sha1, 1).md5($sha3.$sha2, 1);<br />
	return $NewPassword;<br />
}</p>
<p></code><br />
Collisions? Maybe. 1 for pow(2,512);<br />
but the ideia here is protect your users.</p>
<p>Ps: Sorry my English.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: richard</title>
		<link>http://www.richardlord.net/blog/php-password-security/comment-page-1#comment-26684</link>
		<dc:creator>richard</dc:creator>
		<pubDate>Sat, 01 Dec 2007 10:58:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/php-password-security/#comment-26684</guid>
		<description>Nyna

Yes, due to potential collisions, a dictionary attack via the web interface is very slightly less secure than otherwise. But such attacks should &lt;a href=&quot;http://www.google.co.uk/search?q=preventing+dictionary+attacks&quot; rel=&quot;nofollow&quot; rel=&quot;nofollow&quot;&gt;prevented by other means&lt;/a&gt;. If you don&#039;t protect against dictionary attacks then your site is vulnerable whether you use a hash or not, and if you do then it&#039;s secure whether you use a hash or not.

The purpose of the hash is to protect against other types of attack that involve direct theft of your data.

You misunderstand the salt. Unlike a blowfish encryption key, the salt does not need to be secret for the hash to be secure. It only matters that the salt is used and is different for each password. The salt doesn&#039;t protect against decryption (the nature of the hash algorithm does this), it protects against a rainbow table attack (a variant on a dictionary attack for hashed values).

Most companies who have lost their databases considered their security to be very good, yet the databases were still stolen. A similar level of security exists for your encryption key. If a criminal does access your server then they can access both your database and your encryption key.

And don&#039;t assume hacking your production server is the only way in - Do you have backups or development servers that hold the code that contains the encryption key? How many employees know or have ready access to the encryption key? And do any other people have physical access to one of these systems?

With the hash algorithm above, criminals cannot find the passwords by hacking the server or stealing backups. Even I can&#039;t find my users&#039; passwords.</description>
		<content:encoded><![CDATA[<p>Nyna</p>
<p>Yes, due to potential collisions, a dictionary attack via the web interface is very slightly less secure than otherwise. But such attacks should <a href="http://www.google.co.uk/search?q=preventing+dictionary+attacks" rel="nofollow" rel="nofollow">prevented by other means</a>. If you don&#8217;t protect against dictionary attacks then your site is vulnerable whether you use a hash or not, and if you do then it&#8217;s secure whether you use a hash or not.</p>
<p>The purpose of the hash is to protect against other types of attack that involve direct theft of your data.</p>
<p>You misunderstand the salt. Unlike a blowfish encryption key, the salt does not need to be secret for the hash to be secure. It only matters that the salt is used and is different for each password. The salt doesn&#8217;t protect against decryption (the nature of the hash algorithm does this), it protects against a rainbow table attack (a variant on a dictionary attack for hashed values).</p>
<p>Most companies who have lost their databases considered their security to be very good, yet the databases were still stolen. A similar level of security exists for your encryption key. If a criminal does access your server then they can access both your database and your encryption key.</p>
<p>And don&#8217;t assume hacking your production server is the only way in &#8211; Do you have backups or development servers that hold the code that contains the encryption key? How many employees know or have ready access to the encryption key? And do any other people have physical access to one of these systems?</p>
<p>With the hash algorithm above, criminals cannot find the passwords by hacking the server or stealing backups. Even I can&#8217;t find my users&#8217; passwords.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
