Debian Codegraph @

lib/3rdParty/composer/facile-it/php-jose-verifier/src/Internal/functions/derived_key.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Facile\JoseVerifier;
6
7 use Base64Url\Base64Url;
8 use Jose\Component\Core\JWK;
9
10 use function hash;
11 use function round;
12 use function substr;
13
14 /**
15 * @internal
16 */
17 function derived_key(string $secret, int $length): JWK
18 {
19 $hash = substr(hash('sha256', $secret, true), 0, (int) round($length / 8));
20
21 return new JWK([
22 'k' => Base64Url::encode($hash),
23 'kty' => 'oct',
24 ]);
25 }