Files
liche/market/helpers/authorization_helper.php
2022-09-29 14:32:58 +08:00

29 lines
538 B
PHP

<?php
require_once APPPATH . 'libraries/JWT.php';
use \Firebase\JWT\JWT;
class Authorization
{
public static function validateToken($token)
{
$CI =& get_instance();
$key = $CI->config->item('jwt_key');
$algorithm = $CI->config->item('jwt_algorithm');
return JWT::decode($token, $key, array($algorithm));
}
public static function generateToken($data)
{
$CI =& get_instance();
$key = $CI->config->item('jwt_key');
return JWT::encode($data, $key);
}
}