You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-29
Original file line number
Diff line number
Diff line change
@@ -6,67 +6,62 @@
6
6
7
7
# PHP-JWT
8
8
9
-
PHP-JWT is a package written in PHP programming language to encode (generate), decode (parse), verify and validate JWTs
10
-
(JSON Web Tokens). It provides a fluent, easy-to-use, and object-oriented interface.
9
+
PHP-JWT is a PHP programming language package designed for encoding (generation), decoding (parsing), verification, and validation of JSON Web Tokens (JWTs).
10
+
Featuring a fluent, user-friendly, and object-oriented interface.
11
11
12
12
Confirmed by [JWT.io](https://jwt.io).
13
13
14
14
## Documentation
15
15
16
-
### Versions
17
-
* 2.x.x (LTS)
18
-
* 1.x.x (Unsupported)
19
-
20
16
### What is JWT?
21
17
22
-
In case you are unfamiliar with JWT you can read [Wikipedia](https://en.wikipedia.org/wiki/JSON_Web_Token) or
23
-
[JWT.io](https://jwt.io).
18
+
If you're not familiar with JWTs, you can refer to the [Wikipedia page](https://en.wikipedia.org/wiki/JSON_Web_Token) or visit [JWT.io](https://jwt.io) for more information.
24
19
25
20
### Installation
26
21
27
-
Add the package to your Composer dependencies with the following command:
22
+
Include the package in your Composer dependencies using the following command:
28
23
29
24
```bash
30
-
composer require miladrahimi/php-jwt "2.*"
25
+
composer require miladrahimi/php-jwt "3.*"
31
26
```
32
27
33
-
### Simple example
28
+
### Quick Start
34
29
35
-
The following example shows how to generate a JWT and parse it using the *HS256* algorithm.
30
+
Here's an example demonstrating how to generate a JWT and parse it using the `HS256` algorithm:
36
31
37
32
```php
38
33
use MiladRahimi\Jwt\Generator;
39
34
use MiladRahimi\Jwt\Parser;
40
35
use MiladRahimi\Jwt\Cryptography\Algorithms\Hmac\HS256;
41
36
42
-
// Use HS256 to generate and parse tokens
37
+
// Use HS256 to generate and parse JWTs
43
38
$signer = new HS256('12345678901234567890123456789012');
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.
91
+
You can refer to [this instruction](https://en.wikibooks.org/wiki/Cryptography/Generate_a_keypair_using_OpenSSL) to learn how to generate a pair of RSA keys,
92
+
one for public use and the other for private use, using OpenSSL.
93
+
94
+
### ECDSA Algorithms
95
+
96
+
The ECDSA algorithm, like RSA, operates asymmetrically, providing a comparably secure solution while offering heightened security measures.
97
+
This package supports ES256, ES256K, and RS384 ECDSA algorithms.
98
+
The example below demonstrates this process.
99
+
100
+
```php
101
+
use MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa\ES384Signer;
102
+
use MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa\ES384Verifier;
103
+
use MiladRahimi\Jwt\Cryptography\Keys\EcdsaPrivateKey;
104
+
use MiladRahimi\Jwt\Cryptography\Keys\EcdsaPublicKey;
105
+
use MiladRahimi\Jwt\Generator;
106
+
use MiladRahimi\Jwt\Parser;
107
+
108
+
// Generate a token
109
+
$privateKey = new EcdsaPrivateKey('/path/to/private.pem');
0 commit comments