@@ -17,6 +17,17 @@ If you are new to JWT or want to refresh your familiarity with it, please check
17
17
composer require adhocore/jwt
18
18
```
19
19
20
+ ## Features
21
+
22
+ - Six algorithms supported:
23
+ ```
24
+ 'HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512'
25
+ ```
26
+ - ` kid ` support
27
+ - Leeway support 0-120 seconds.
28
+ - Timestamp spoofing for tests.
29
+ - Passphrase support for ` RS* ` algos.
30
+
20
31
## Usage
21
32
22
33
``` php
@@ -93,15 +104,19 @@ $jwt->parse($token);
93
104
$jwt->setTestTimestamp();
94
105
```
95
106
96
- ## Features
107
+ > Examples with ` kid ` :
97
108
98
- - Six algorithms supported:
99
- ```
100
- 'HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512'
109
+ ``` php
110
+ $jwt = new JWT(['key1' => 'secret1', 'key2' => 'secret2']);
111
+
112
+ // Use key2
113
+ $token = $jwt->encode(['a' => 1, 'exp' => time() + 1000], ['kid' => 'key2']);
114
+
115
+ $payload = $jwt->decode($token);
116
+
117
+ $token = $jwt->encode(['a' => 1, 'exp' => time() + 1000], ['kid' => 'key3']);
118
+ // -> Exception with message Unknown key ID key3
101
119
```
102
- - Leeway support 0-120 seconds.
103
- - Timestamp spoofing for tests.
104
- - Passphrase support for ` RS* ` algos.
105
120
106
121
### Integration
107
122
0 commit comments