-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
49 lines (39 loc) · 947 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
use hasanparasteh\SecureJWT;
require "vendor/autoload.php";
//$jwt = new SecureJWT();
//$keypair = $jwt->createKeyPair("/tmp");
//if (is_bool($keypair) && $keypair === false) {
// echo "ERROR: Failed to generate keypair" . PHP_EOL;
// exit;
//}
//
//$publicKey = $keypair['public_key'];
//$privateKey = $keypair['private_key'];
//
//echo "public key is: " . $publicKey . PHP_EOL;
//echo "private key is: " . $privateKey . PHP_EOL;
//
//echo PHP_EOL . PHP_EOL;
$payload = [
"userId" => 6
];
$encodeInfo = [
$payload,
'Hasan Parasteh', // iss
'test', // sub
'github', // aud
'secret', // key
'2 hour' // exp
];
$token = SecureJWT::encodeJWT(...$encodeInfo);
echo "Token is: " . $token . PHP_EOL;
$decodeInfo = [
$token,
'Hasan Parasteh', // iss
'test', // sub
'github', // aud
'secret', // key
];
$payload = SecureJWT::decodeJWT(...$decodeInfo);
echo json_encode($payload, 128);