I would opt for storing salt along with hashing algorithm's identifier and the hash itself.
Here is why:
Usually the the access to database is limited to localhost
or some predefined range of IP addresses. Which means that, for a hacker to gain access to your database, he/she would need to compromise your servers filesystem (either by gaining direct access or injecting a script). Or perform an SQL injection.
In the former case it would mean, that if someone gained access to your salts in DB, he/she could as easily read them from your PHP files source.
The latter cause can be simply prevented by use of prepared statements with either PDO or MySQLi. You shouldn't be using the old mysql_*
functions as API anymore. They are not maintained anymore and the process of deprecation has begun already.
Even if someone gets his/her hands on your DB, it is not all that problematic. If you are using crypt()
function for creating hashes with good algorithms (recommended would be CRYPT_BLOWFISH
), then cracking even a single password can be exceedingly long (in the scale of years). By that time you can easily send out "change your password" notifications to users, and lock all the ones, who have not done so.
If you are using PHP 5.5+, you should instead be using the new password API: http://php.net/password