wp_verify_fast_hash()WP 6.8.0

Checks whether a plaintext message matches the hashed value. Used to verify values hashed via wp_fast_hash().

The function uses Sodium to hash the message and compare it to the hashed value. If the hash is not a generic hash, the hash is treated as a phpass portable hash in order to provide backward compatibility for passwords and security keys which were hashed using phpass prior to WordPress 6.8.0.

Хуков нет.

Возвращает

true|false. Whether the message matches the hashed message.

Использование

wp_verify_fast_hash( string $message, $hash ): bool;
string $message(обязательный)

.

Иммет атрибут #[\SensitiveParameter], который скрывает значение параметра из логов. Используется для защиты чувствительных данных (например, паролей). Документация.

$hash(строка) (обязательный)
Hash of the message to check against.

Список изменений

С версии 6.8.0 Введена.

Код wp_verify_fast_hash() WP 7.0.2

function wp_verify_fast_hash(
	#[\SensitiveParameter]
	string $message,
	string $hash
): bool {
	if ( ! str_starts_with( $hash, '$generic$' ) ) {
		// Back-compat for old phpass hashes.
		require_once ABSPATH . WPINC . '/class-phpass.php';
		return ( new PasswordHash( 8, true ) )->CheckPassword( $message, $hash );
	}

	return hash_equals( $hash, wp_fast_hash( $message ) );
}