FileAccess Orion

MyJwt
in package

Define abstraction layer for jwt token encode and decode

To create the secrets use the following commands. First create the private key, then the public key, finally remove the passphrase

openssl genrsa -out jwt-secret.pem -passout "pass:mypassword" -aes256 4096 openssl rsa -pubout -passin "pass:mypassword" -in jwt-secret.pem -out jwt-shared.pem openssl rsa -passin "pass:mypassword" -in jwt-secret.pem -out jwt-secret.pem

Table of Contents

$alg  : string
$code  : string|null
The value of the private key
$public_code  : Key|null
The value of the shared secret
__construct()  : mixed
Construct using secret from shared file
decode()  : object|null
Decode token and verify
encode()  : string|null
Encode the given object / array

Properties

$alg

private string $alg = 'RS256'

$code

The value of the private key

private string|null $code = null

$public_code

The value of the shared secret

private Key|null $public_code = null

Methods

__construct()

Construct using secret from shared file

public __construct() : mixed
Return values
mixed

decode()

Decode token and verify

public decode(string $data) : object|null
Parameters
$data : string
Return values
object|null

encode()

Encode the given object / array

public encode([array<string|int, mixed> $data = array() ]) : string|null
Parameters
$data : array<string|int, mixed> = array()

The data to encode and sign

Return values
string|null

Search results