# wp_hash()

URL: https://chugunov.pro/api-wordpress/functions/wp_hash/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.0.3.

## Сигнатура

```php
wp_hash( string $data, string $scheme = 'auth', string $algo = 'md5' ): string
```

## Описание

Алгоритм по умолчанию — md5, но его можно изменить на любой алгоритм, поддерживаемый hash_hmac(). Используйте функцию hash_hmac_algos() для проверки поддерживаемых алгоритмов.

## Параметры

- `$data` `string` — обязательный. Открытый текст для хеширования.
- `$scheme` `string` — необязательный, по умолчанию `'auth'`. Схема аутентификации (auth, secure_auth, logged_in, nonce).
- `$algo` `string` — необязательный, по умолчанию `'md5'`. Алгоритм хеширования для использования. По умолчанию: 'md5'.

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-includes/pluggable.php:2715`

```php
function wp_hash( $data, $scheme = 'auth', $algo = 'md5' ) {
	$salt = wp_salt( $scheme );

	// Ensure the algorithm is supported by the hash_hmac function.
	if ( ! in_array( $algo, hash_hmac_algos(), true ) ) {
		throw new InvalidArgumentException(
			sprintf(
				/* translators: 1: Name of a cryptographic hash algorithm. 2: List of supported algorithms. */
				__( 'Unsupported hashing algorithm: %1$s. Supported algorithms are: %2$s' ),
				$algo,
				implode( ', ', hash_hmac_algos() )
			)
		);
	}

	return hash_hmac( $algo, $data, $salt );
}
```

## История изменений

- 6.8.0 — The $algo parameter was added.
- 2.0.3 — Introduced.

## Связанные

Использует: [`wp_salt`](https://chugunov.pro/api-wordpress/functions/wp_salt/), [`__`](https://chugunov.pro/api-wordpress/functions/__/).
Используется в: `WP_REST_Widgets_Controller::prepare_item_for_response`, `WP_REST_Widgets_Controller::save_widget`, `WP_REST_Widget_Types_Controller::encode_form_data`, [`wp_get_unapproved_comment_author_email`](https://chugunov.pro/api-wordpress/functions/wp_get_unapproved_comment_author_email/), `WP_Customize_Nav_Menus::hash_nav_menu_args`, [`wp_verify_nonce`](https://chugunov.pro/api-wordpress/functions/wp_verify_nonce/), [`wp_create_nonce`](https://chugunov.pro/api-wordpress/functions/wp_create_nonce/), [`wp_validate_auth_cookie`](https://chugunov.pro/api-wordpress/functions/wp_validate_auth_cookie/), [`wp_generate_auth_cookie`](https://chugunov.pro/api-wordpress/functions/wp_generate_auth_cookie/), `WP_Customize_Widgets::get_instance_hash_key`.

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_hash/
