PHP code example of mrmiao / think-interface-encryption

1. Go to this page and download the library: Download mrmiao/think-interface-encryption library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mrmiao / think-interface-encryption example snippets

`

namespace app\index\controller;

//引用RSACrypt加密类
use mrmiao\encryption\RSACrypt;

class Index
{
    //在方法中实例化加密类
    function encrypt(RSACrypt $crypt){
        //调用request()方法获取请求参数,request方法可选参数数组['参数名'=>'强制转换类型']
        $param = $crypt->request(['user_id'=>'int','mobile'=>'array','quest_time'=>'int','app_id'=>'string']);
        //解析后参数变为明文数据
        $param['php_add'] = '正常使用参数数据';
        //调用response()方法返回数据,参数为数组
        return $crypt->response(['code'=>200,'message'=>'success','data'=>$param],true);
    }
}