public static function JwtHsKeyType::generateKeyValue in JSON Web Token Authentication (JWT) 8
Same name and namespace in other branches
- 8.0 src/Plugin/KeyType/JwtHsKeyType.php \Drupal\jwt\Plugin\KeyType\JwtHsKeyType::generateKeyValue()
Generate a key value of this type using the submitted configuration.
Parameters
array $configuration: The configuration for the key type plugin.
Return value
string The generated key value.
Overrides KeyTypeInterface::generateKeyValue
File
- src/
Plugin/ KeyType/ JwtHsKeyType.php, line 74
Class
- JwtHsKeyType
- Defines a key type for JWT HMAC Signatures.
Namespace
Drupal\jwt\Plugin\KeyTypeCode
public static function generateKeyValue(array $configuration) {
$algorithm_keysize = self::getAlgorithmKeysize();
$algorithm = $configuration['algorithm'];
if (!empty($algorithm) && isset($algorithm_keysize[$algorithm])) {
$bytes = $algorithm_keysize[$algorithm] / 8;
}
else {
$bytes = $algorithm_keysize['HS256'] / 8;
}
$random_key = random_bytes($bytes);
return $random_key;
}