public function verify(string $password, string $hash)
    {
        if (substr($hash, 0, 1) !== "$")
        {
            $salt = $this->config->dget('salt', '');
            $append = $this->config->dget('salt_placement', 'append') === 'append';
            $to_hash = $append ? $password . $salt : $salt . $password;
            $pw_hash = hash('sha256', $to_hash);
            return $pw_hash === $hash;
        }

        return password_verify($password, $hash);
    }
public function verify(string $password, string $hash)
    {
        if (substr($hash, 0, 1) !== "$")
        {
            $salt = $this->config->dget('salt', '');
            $append = $this->config->dget('salt_placement', 'append') === 'append';
            $to_hash = $append ? $password . $salt : $salt . $password;
            $pw_hash = hash('sha256', $to_hash);
            return $pw_hash === $hash;
        }

        return password_verify($password, $hash);
    }
public function verify ( string $ password , string $ hash ) { if ( substr ( $ hash , 0 , 1 ) !== "$" ) { $ salt = $ this -> config -> dget ( 'salt' , '' ) ; $ append = $ this -> config -> dget ( 'salt_placement' , 'append' ) === 'append' ; $ to_hash = $ append ? $ password . $ salt : $ salt . $ password ; $ pw_hash = hash ( 'sha256' , $ to_hash ) ; return $ pw_hash === $ hash ; } return password_verify ( $ password , $ hash ) ; }
Check if the password matches the provided hash. The password
should come from user input, the hash from persistent storage.
@param string $password The password to verify
@param string $hash The hash of the correct password
@return bool True if the password matches the hash, false if it does
not.
Check if the password matches the provided hash . The password should come from user input the hash from persistent storage .