jsnlib / codeigniter_encryption
1.0.2
2018-03-30 04:29 UTC
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-08-29 04:54:18 UTC
README
示例
class Welcome extends CI_Controller { public function index() { // 1. 使用 encryption 類別 $this->load->library('encryption'); // 2. 初始化並在建構子置入 CI 原生的 encryption 物件 $this->jsnlib_ecp = new \Jsnlib\Codeigniter\Encryption($this->encryption); // 3. 產生加密字串 $token = $this->jsnlib_ecp->encrypt( [ 'name' => 'Jason', 'age' => 18, 'expiry' => '2019-01-01 10:00:00' //若不指定過期時間,將自動添加預設值 ]); // 4. 解密字串 $ary = $this->jsnlib_ecp->decrypt($token); } }
说明
encrypt(array $param): string
@param expiry 若未指定过期时间,将自动添加默认值
@return 以 base64 格式输出加密后的数据
decrypt(string $encrypt): array
@param encrypt 加密的文本
@return is_expired 是否已过期
@return data 加密前的原始数据