Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 15... Línea 15...
15
```bash
15
```bash
16
composer require firebase/php-jwt
16
composer require firebase/php-jwt
17
```
17
```
Línea 18... Línea 18...
18
 
18
 
19
Optionally, install the `paragonie/sodium_compat` package from composer if your
19
Optionally, install the `paragonie/sodium_compat` package from composer if your
Línea 20... Línea 20...
20
php is < 7.2 or does not have libsodium installed:
20
php env does not have libsodium installed:
21
 
21
 
22
```bash
22
```bash
Línea 46... Línea 46...
46
$jwt = JWT::encode($payload, $key, 'HS256');
46
$jwt = JWT::encode($payload, $key, 'HS256');
47
$decoded = JWT::decode($jwt, new Key($key, 'HS256'));
47
$decoded = JWT::decode($jwt, new Key($key, 'HS256'));
48
print_r($decoded);
48
print_r($decoded);
Línea 49... Línea 49...
49
 
49
 
-
 
50
// Pass a stdClass in as the third parameter to get the decoded header values
50
// Pass a stdClass in as the third parameter to get the decoded header values
51
$headers = new stdClass();
51
$decoded = JWT::decode($jwt, new Key($key, 'HS256'), $headers = new stdClass());
52
$decoded = JWT::decode($jwt, new Key($key, 'HS256'), $headers);
Línea 52... Línea 53...
52
print_r($headers);
53
print_r($headers);
53
 
54
 
54
/*
55
/*