Yoast\WP\SEO\MyYoast_Client\Infrastructure\Crypto

Key_Pair::__constructpublicYoast 1.0

Key_Pair constructor.

Метод класса: Key_Pair{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$Key_Pair = new Key_Pair();
$Key_Pair->__construct( string $public_key,;

Код Key_Pair::__construct() Yoast 27.7

public function __construct(
	string $public_key,
	// phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPNativeAttributeFound -- No-op on PHP < 8.2; redacts parameter from stack traces on PHP 8.2+.
	#[SensitiveParameter]
	string $private_key,
	string $kid
) {
	if ( \strlen( $public_key ) !== \SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES ) {
		throw new InvalidArgumentException(
			// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
			\sprintf( 'Public key must be %d bytes, got %d.', \SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES, \strlen( $public_key ) ),
		);
	}
	if ( \strlen( $private_key ) !== \SODIUM_CRYPTO_SIGN_SECRETKEYBYTES ) {
		throw new InvalidArgumentException(
			// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
			\sprintf( 'Private key must be %d bytes, got %d.', \SODIUM_CRYPTO_SIGN_SECRETKEYBYTES, \strlen( $private_key ) ),
		);
	}

	$this->public_key  = $public_key;
	$this->private_key = $private_key;
	$this->kid         = $kid;
}