creste secret key

This commit is contained in:
2024-10-22 16:40:40 +03:00
parent 7ccf0957bf
commit c9fe2f160a
10 changed files with 136 additions and 19 deletions

View File

@ -0,0 +1,29 @@
<?php
namespace kernel\services;
use Firebase\JWT\JWT;
use Random\RandomException;
class TokenService
{
public static function JWT(string|\OpenSSLCertificate|\OpenSSLAsymmetricKey $key, string $alg, array $payload = []): string
{
return JWT::encode(
payload: $payload,
key: $key,
alg: $alg
);
}
/**
* @throws RandomException
*/
public static function random_bytes(int $ln): string
{
$token = random_bytes($ln);
return bin2hex($token);
}
}