. , , . .
function generateSalt($length = null)
{
if (!is_int($length) || ($length < 1)) $length = 250;
do {
$salt[] = chr(mt_rand(0, 255));
} while (--$length);
return implode('', $salt);
}
update user set salt = :salt, password = sha1(concat(:password, :salt)) where id = :id limit 1;
.
select * from user where id = :id and password = sha1(concat(:password, salt)) limit 1;