note 66235 deleted from function.md5 by joey
| From: | joey@php.net | Date: | Sun, 17 Jul 2011 08:41:34 +0000 |
| Subject: | note 66235 deleted from function.md5 by joey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181610@lists.php.net to get a copy of this message | ||
Note Submitter: coryostrudel at godcomplex dot com
----
If you are storing your passwords with and MD5 hash and are worried about collisions, an approach I
have used was to store two passwords for the user.
credentials
----------
userName
password
passwordChk
Where:
$input - users input password
$key - a site based key stored out of public folders
password = MD5($key.strrev($input))
passwordChk = MD5($input{0}.substr($input,(floor(strlen($input))/2),strlen))
This will stored the users password in the database as an MD5 hash of the string reversed plus a
site based key stored out of public folders.
It also stores a check value to check that the input is the true input and not a colliding value.
The check takes the first character appends a substring of the input taking the last half of the
input string and creates and MD5.
I think this is pretty secure. It takes a modified salt & pepper approach, and follows up with
a check on the original input to make sure it is not a colliding value, while also not storing the
original password in plain text.