-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJWT.php
37 lines (32 loc) · 854 Bytes
/
JWT.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
* JSON Web Tokens (JWT) Class
*
* @author Nabi KaramAliZadeh <[email protected]>
* @link www.nabi.ir
* @project https://github.com/NabiKAZ/yii-jwt
* @since 2017-03-09
* @version 1.0
* @license GNU General Public License v3
* @copyright 2017 Nabi Karamalizadeh
*
*/
class JWT
{
public $key;
public function init()
{
require dirname(__FILE__) . '/src/JWT.php';
require dirname(__FILE__) . '/src/BeforeValidException.php';
require dirname(__FILE__) . '/src/ExpiredException.php';
require dirname(__FILE__) . '/src/SignatureInvalidException.php';
}
public function encode($payload)
{
return \Firebase\JWT\JWT::encode($payload, $this->key);
}
public function decode($msg)
{
return \Firebase\JWT\JWT::decode($msg, $this->key, array('HS256'));
}
}