wp_hash()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_hash( string $data, string $scheme = 'auth', string $algo = 'md5' ): string
Описание
Алгоритм по умолчанию — md5, но его можно изменить на любой алгоритм, поддерживаемый hash_hmac(). Используйте функцию hash_hmac_algos() для проверки поддерживаемых алгоритмов.
Оригинал (английский)
The default algorithm is md5 but can be changed to any algorithm supported by hash_hmac(). Use the hash_hmac_algos() function to check the supported algorithms.
Параметры
$data
string
обязательный
$scheme
string
необязательный
= 'auth'
$algo
string
необязательный
= 'md5'
Возвращаемое значение
string
Исходный код
wp-includes/pluggable.php:2715
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. |

