Commit aba60bec authored by hujun's avatar hujun

getJwtToken

parent f762bb2d
......@@ -156,6 +156,26 @@ class Basic extends Controller
'Access-Defined-X-Servers' => 'Guangzhou Cuci Technology Co. Ltd',
];
}
/**
* 加密token或解码token
* @param type $data 加密token
* @param type $token 解密token
* @return type
*/
public static function getJwtToken($data, $token = '') {
$jwt = new \Firebase\JWT\JWT();
if ($token) {
$result = $jwt->decode($token, config('jwt_key'), array('HS256')); //解码token
} else {
$data_arr['expire'] = time();
$data_arr['data'] = $data;
$result = $jwt->encode($data, config('jwt_key')); //生成token
}
return $result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment