本文整理匯總了PHP中Key::getRawKeyMaterial方法的典型用法代碼示例。如果您正苦於以下問題:PHP Key::getRawKeyMaterial方法的具體用法?PHP Key::getRawKeyMaterial怎麽用?PHP Key::getRawKeyMaterial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Key
的用法示例。
在下文中一共展示了Key::getRawKeyMaterial方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getSharedSecret
/**
* Diffie-Hellman, ECDHE, etc.
*
* Get a shared secret from a private key you possess and a public key for
* the intended message recipient
*
* @param EncryptionSecretKey $privateKey
* @param EncryptionPublicKey $publicKey
* @param bool $get_as_object Get as a Key object?
* @return string
*/
public static function getSharedSecret(Key $privateKey, Key $publicKey, bool $get_as_object = false)
{
if ($get_as_object) {
return new EncryptionKey(\Sodium\crypto_scalarmult($privateKey->getRawKeyMaterial(), $publicKey->getRawKeyMaterial()));
}
return \Sodium\crypto_scalarmult($privateKey->getRawKeyMaterial(), $publicKey->getRawKeyMaterial());
}
示例2: splitKeys
/**
* Split a key using HKDF-BLAKE2b
*
* @param Key $master
* @param string $salt
* @param Config $config
* @return string[]
*/
protected static function splitKeys(Key $master, string $salt = '', Config $config = null) : array
{
$binary = $master->getRawKeyMaterial();
return [Util::hkdfBlake2b($binary, \Sodium\CRYPTO_SECRETBOX_KEYBYTES, $config->HKDF_SBOX, $salt), Util::hkdfBlake2b($binary, \Sodium\CRYPTO_AUTH_KEYBYTES, $config->HKDF_AUTH, $salt)];
}