public static function verify(string $data, string $hash, string $pass): bool
    {
        // Get the salt value from the decrypted prefix
        $salt = Str::substr($hash, 0, 16);

        // Get the encrypted cost bytes out of the blob
        $chsh = Str::substr($hash, 16, 8);

        // Get the encrypted cost bytes out of the blob
        $cost = Str::substr($hash, 24, 4);

        // If the provided cost hash does not calculate to be the same as the one provided then consider the hash invalid.
        if ($chsh !== self::costHash($cost, $pass)) {
            return false;
        }

        // Decrypt the cost value stored in the 32bit int
        $cost = self::costDecrypt($cost, $salt, $pass);

        // Build a hash from the input for comparison
        $calc = self::build($data, $pass, $cost, $salt);

        // Return the boolean equivalence
        return Str::equal($hash, $calc);
    }
public static function verify(string $data, string $hash, string $pass): bool
    {
        // Get the salt value from the decrypted prefix
        $salt = Str::substr($hash, 0, 16);

        // Get the encrypted cost bytes out of the blob
        $chsh = Str::substr($hash, 16, 8);

        // Get the encrypted cost bytes out of the blob
        $cost = Str::substr($hash, 24, 4);

        // If the provided cost hash does not calculate to be the same as the one provided then consider the hash invalid.
        if ($chsh !== self::costHash($cost, $pass)) {
            return false;
        }

        // Decrypt the cost value stored in the 32bit int
        $cost = self::costDecrypt($cost, $salt, $pass);

        // Build a hash from the input for comparison
        $calc = self::build($data, $pass, $cost, $salt);

        // Return the boolean equivalence
        return Str::equal($hash, $calc);
    }
public static function verify ( string $ data , string $ hash , string $ pass ) : bool { // Get the salt value from the decrypted prefix $ salt = Str :: substr ( $ hash , 0 , 16 ) ; // Get the encrypted cost bytes out of the blob $ chsh = Str :: substr ( $ hash , 16 , 8 ) ; // Get the encrypted cost bytes out of the blob $ cost = Str :: substr ( $ hash , 24 , 4 ) ; // If the provided cost hash does not calculate to be the same as the one provided then consider the hash invalid. if ( $ chsh !== self :: costHash ( $ cost , $ pass ) ) { return false ; } // Decrypt the cost value stored in the 32bit int $ cost = self :: costDecrypt ( $ cost , $ salt , $ pass ) ; // Build a hash from the input for comparison $ calc = self :: build ( $ data , $ pass , $ cost , $ salt ) ; // Return the boolean equivalence return Str :: equal ( $ hash , $ calc ) ; }
Check the validity of a hash.

@param string $data Input to test.
@param string $hash Known hash to validate against.
@param string $pass HMAC password to use during iterative hash.
@return boolean
Check the validity of a hash .