Skip to content

Commit

Permalink
up init
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Sep 15, 2019
1 parent 11e8b40 commit 95d9bf3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ composer require easyswoole/jwt

require 'vendor/autoload.php';

/** @var \EasySwoole\Jwt\Object $obj */
/** @var \EasySwoole\Jwt\JwtObject $obj */
//设置加密方式 支持AES 与 HMACSHA256 设置密钥默认为EasySwoole
$obj = \EasySwoole\Jwt\Jwt::getInstance()->algMethod('AES')->setSecretKey('测试呀')->publish();

Expand All @@ -44,7 +44,7 @@ $jwt = \EasySwoole\Jwt\Jwt::getInstance();

try{
//验证token,解密并验证签名验证过期时间
/** @var \EasySwoole\Jwt\Object $result */
/** @var \EasySwoole\Jwt\JwtObject $result */
$result = $jwt -> decode($token);

var_dump($result);
Expand Down
10 changes: 5 additions & 5 deletions src/Jwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ function algMethod(string $method):Jwt
return $this;
}

public function publish():Object
public function publish():JwtObject
{
$obj = new Object();
$obj = new JwtObject();
$obj->setAlg($this->alg);
return $obj;
}

public function decode(?string $raw):?Object
public function decode(?string $raw):?JwtObject
{
$raw = json_decode(base64_decode(urldecode($raw)),true);
if(empty($raw['signature'])){
throw new Exception("signature is empty");
}
return new Object($raw,true);
return new JwtObject($raw,true);
}


public function __signature(Object $object):?string
public function __signature(JwtObject $object):?string
{
$array = $object->toArray();
unset($array['signature']);
Expand Down
2 changes: 1 addition & 1 deletion src/Object.php → src/JwtObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use EasySwoole\Spl\SplBean;
use EasySwoole\Utility\Random;

class Object extends SplBean
class JwtObject extends SplBean
{
const STATUS_OK = 1;
const STATUS_SIGNATURE_ERROR = -1;
Expand Down

0 comments on commit 95d9bf3

Please sign in to comment.