PHPackages                             mrmiao/think-interface-encryption - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. mrmiao/think-interface-encryption

ActiveThink-interface-encryption[Security](/categories/security)

mrmiao/think-interface-encryption
=================================

Base on TP framework encrypt the JSON-type interface request and return data by using the RSA algorithm

1.08(9y ago)1237PHP

Since Apr 21Pushed 9y ago1 watchersCompare

[ Source](https://github.com/896845927/think-interface-encryption)[ Packagist](https://packagist.org/packages/mrmiao/think-interface-encryption)[ RSS](/packages/mrmiao-think-interface-encryption/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (9)DependenciesVersions (10)Used By (0)

think-interface-encryption
==========================

[](#think-interface-encryption)

Encrypt the JSON-type interface request and return data by using the RSA

### 这个扩展包深度依赖TP5框架

[](#这个扩展包深度依赖tp5框架)

- 使用到大量的tp框架下的帮助函数
- 加密类依赖了框架的配置文件的自动加载模式
- 加密类配置文件生成依赖了框架的命令行方式

### 预定义了异常 code

[](#预定义了异常-code)

- 100 缺少配置文件
- 101 请求参数解析失败
- 102 请求方式错误
- 103 请求参数数量与规则不符
- 104 错误的请求参数

### 请求参数支持严格规则

[](#请求参数支持严格规则)

- $rule 严格设定的参数规则,\['参数名'=&gt;'参数类型'\]
- 参数类型包括,会强制转换类型
- array 数组
- int 整数
- float 浮点数
- boolean 布尔值
- string 字串

### 注意

[](#注意)

- 配置文件rsa\_config.php位于 application/extra目录下
- debug设置,本地开发环境中设为 true,调试模式; 线上环境中设为 false,接口模式;
- 在接口模式下,请求强制要求为json类型
- 在接口模式下,请求数据统一强制使用$\_REQUEST\['param'\]来获取(既app端统一请求param来放置请求密文数据)

### 命令行生成配置文件

[](#命令行生成配置文件)

- 在项目目录下使用命令行命令 php think MakeRSAConfig

### 对接app

[](#对接app)

- 需要提供给APP端rsa\_config配置文件里的 request\_pubKey 和 response\_privKey

### 如何设置明文请求调试

[](#如何设置明文请求调试)

- 在rsa\_config\_path文件中将debug设置为true

### 调用示例

[](#调用示例)

```
