"" , AFAIK, addslashes().
:.
$hash = hash('sha1', $username . $salt . $password, true);
$query_safe_hash = addslashes($hash);
$query_safe_username = addslashes($username);
$query = "INSERT INTO DBTable(username, password) VALUES ('$query_safe_username', '$query_safe_hash')";
mysql_query($query) or die("Failed to store credentials!");
: , , . -
$salt = generate_random_salt();
$query_safe_hash = addslashes($salt) . addslashes(hash('sha1', $salt . $username . $password, true);
Then, in order to verify the user credentials, you retrieve the stored hash, delete slashes and remove the known salt length from the beginning of the stored hash and use the same salt to generate a hash of the provided credentials, and then compare. This helps to strengthen your hash algorithm against various cryptanalytic attacks (in particular, differential cryptanalysis).
source
share