Skip to content

Commit 293a658

Browse files
authored
Update README.md
1 parent 448e44e commit 293a658

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,23 @@ use MiladRahimi\Jwt\Cryptography\Keys\RsaPublicKey;
7676
use MiladRahimi\Jwt\Generator;
7777
use MiladRahimi\Jwt\Parser;
7878

79+
// Generate a token
7980
$privateKey = new RsaPrivateKey('/path/to/private.pem');
80-
$publicKey = new RsaPublicKey('/path/to/public.pem');
81-
8281
$signer = new RS256Signer($privateKey);
83-
$verifier = new RS256Verifier($publicKey);
84-
85-
// Generate a token
8682
$generator = new Generator($signer);
8783
$jwt = $generator->generate(['id' => 666, 'is-admin' => true]);
8884

8985
// Parse the token
86+
$publicKey = new RsaPublicKey('/path/to/public.pem');
87+
$verifier = new RS256Verifier($publicKey);
9088
$parser = new Parser($verifier);
9189
$claims = $parser->parse($jwt);
9290

93-
echo $claims; // ['id' => 666, 'is-admin' => true]
91+
print_r($claims); // ['id' => 666, 'is-admin' => true]
9492
```
9593

96-
You can read [this instruction](https://en.wikibooks.org/wiki/Cryptography/Generate_a_keypair_using_OpenSSL) to learn how to generate a pair (public/private) RSA key.
94+
You can read [this instruction](https://en.wikibooks.org/wiki/Cryptography/Generate_a_keypair_using_OpenSSL)
95+
to learn how to generate a pair (public/private) RSA key.
9796

9897
### Validation
9998

0 commit comments

Comments
 (0)