Yoast\WP\SEO\MyYoast_Client\Infrastructure\Crypto
Encryption::derive_key
Derives a 256-bit encryption key from AUTH_KEY using HKDF-SHA256.
Метод класса: Encryption{}
Хуков нет.
Возвращает
Строку. A 32-byte derived key.
Использование
// private - только в коде основоного (родительского) класса $result = $this->derive_key( $context ): string;
- $context(строка) (обязательный)
- A unique context string for key derivation.
Код Encryption::derive_key() Encryption::derive key Yoast 27.7
private function derive_key( string $context ): string {
if ( ! \function_exists( 'sodium_crypto_secretbox' ) ) {
throw new Encryption_Exception( 'The sodium PHP extension is required but not available.' );
}
if ( ! \defined( 'AUTH_KEY' ) || \AUTH_KEY === '' || \AUTH_KEY === 'put your unique phrase here' ) {
throw new Encryption_Exception( 'AUTH_KEY is not configured. Please set a unique AUTH_KEY in wp-config.php.' );
}
return \hash_hkdf( 'sha256', \AUTH_KEY, \SODIUM_CRYPTO_SECRETBOX_KEYBYTES, $context );
}