note 54538 added to security.database.storage

From: Date: Thu, 07 Jul 2005 09:05:58 +0000
Subject: note 54538 added to security.database.storage
Groups: php.notes 
Request: Send a blank email to php-notes+get-91578@lists.php.net to get a copy of this message
You could always double hash the password, which might just be the easiest way to prevent a hash table crack which typically can only crack hashes that store about 8 characters in length (from what i know). For an additional amount of security you can always append a random salt, although you will need to store the salt to succesfully recover the password for checking. The code could look like this: <?php function createSalt ($charno = 5) { for ($i = 0; $i < $charno; $i++;) { $num = rand(48, 122); //This is roughly the ascii readable character range $salt .= chr($num); //Convert the number to a real character } return $salt; } $randomsalt = createSalt(); $hash = md5(md5($string_to_hash.$randomsalt)); /* Now append this to your database, but remember to store the salt somewhere too, or else you wont be able to check the password later on */ ?> Easy as pie. Hope this helps. ---- Manual Page -- http://www.php.net/manual/en/security.database.storage.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54538 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54538&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54538&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54538&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54538&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54538&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54538&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54538&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91578) next »