Skip to content

Commit 1b632d0

Browse files
committed
docs: add examples with 'kid'
1 parent 9be3ae9 commit 1b632d0

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

README.md

+22-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ If you are new to JWT or want to refresh your familiarity with it, please check
1717
composer require adhocore/jwt
1818
```
1919

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+
2031
## Usage
2132

2233
```php
@@ -93,15 +104,19 @@ $jwt->parse($token);
93104
$jwt->setTestTimestamp();
94105
```
95106

96-
## Features
107+
> Examples with `kid`:
97108
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
101119
```
102-
- Leeway support 0-120 seconds.
103-
- Timestamp spoofing for tests.
104-
- Passphrase support for `RS*` algos.
105120

106121
### Integration
107122

0 commit comments

Comments
 (0)