creste secret key
This commit is contained in:
29
kernel/services/TokenService.php
Normal file
29
kernel/services/TokenService.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user