I see nothing wrong with storing the salt in the table; in fact i'd recommend it.
Here's how I generate my salt:
PHP Code:
public function generateSalt()
{
$salt = convert_uuencode(
pack(
'H*',
hash_hmac('sha512', uniqid(mt_rand(), true), uniqid(mt_rand(), true))
)
);
$this->setSalt($salt);
return $salt;
}
And my password hashing:
PHP Code:
public function setPlainPassword($password)
{
$password = TPropertyValue::ensureString($password);
$salt = $this->getSalt();
$this->_password = hash_hmac('sha512', $salt . $password . $salt, $salt) . $salt;
}
Bookmarks