Class crJWT
Sample: $secret = 'xx';
$payload = array('email'=>'[email protected]');
echo $jwt = crJWT::encode($payload, $secret);
pp(crJWT::decode($jwt, $secret));
Methods summary
public static
array
|
#
decode( string $jwt, string $secret = null )
decodes a JWT string into an PHP array
decodes a JWT string into an PHP array
Parameters
- $jwt
- $secret
- null to decode only | secret to verify also
Returns
array
Throws
Exception
|
public static
string
|
#
encode( array $payload, string $secret, array $header = null, string $algo = 'HS256' )
converts and signs an array into a JWT string.
converts and signs an array into a JWT string.
Parameters
- $payload
- $secret
- The secret key.
- $header
- additional null => no additional header, 'registered-claims' => for default iat, jit or own array
- $algo
- Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
Returns
string signed JWT
Throws
Exception
|
Properties summary
public static
array
|
$m_supported_algos
|
#
array(
'HS256' => 'sha256',
'HS512' => 'sha512',
'HS384' => 'sha384'
)
|