# think-interface-encryption **Repository Path**: mr_miao/think-interface-encryption ## Basic Information - **Project Name**: think-interface-encryption - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-04-27 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # think-interface-encryption Encrypt the JSON-type interface request and return data by using the RSA ### 安装注意 整个mrmiao目录放置在TP项目的extend目录下 用户需要自己配置 项目/extend/mrmiao/encryption/rsa_config.php 中的两套rsa秘钥(1024位), ### 预定义了异常 code * 100 缺少配置文件 * 101 请求参数解析失败 * 102 请求方式错误 * 103 请求参数数量与规则不符 * 104 错误的请求参数 ### 请求参数支持严格规则 * $rule 严格设定的参数规则,['参数名'=>'参数类型'] * 参数类型包括,会强制转换类型 * array 数组 * int 整数 * float 浮点数 * boolean 布尔值 * string 字串 ### 注意 * 请求强制要求为json类型,请求数据统一强制使用$_REQUEST['param']来获取(既app端统一请求param来放置请求数据) * 配置文件rsa_config.php位于 项目/extend 目录下 * debug设置,本地开发环境中设为 true; 线上环境中设为 false; ### 对接app * 需要提供给APP端rsa_config配置文件里的 request_pubKey 和 response_privKey * 在请求参数param下必须设置'hamburger_coke'=>0,来指定返回数据为明文 ### 如何设置明文请求调试 * 1.请求必须是json字串 * 2.在rsa_config.php文件中将debug设置为true 调用示例 ```` '强制转换类型'] $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]); } } ```