PHPackages                             lazywe/lazy-tools - 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. lazywe/lazy-tools

ActiveLibrary

lazywe/lazy-tools
=================

基于laravel的工具脚手架，支持数据Rsa Aes双重加密

1.0.0(6y ago)08MITPHPCI failing

Since Jan 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/lazywe/lazy-tools)[ Packagist](https://packagist.org/packages/lazywe/lazy-tools)[ RSS](/packages/lazywe-lazy-tools/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

lazy-tools
==========

[](#lazy-tools)

- 基于laravel的工具脚手架，支持数据Rsa Aes双重加密
- 常用函数
- 密文模式
- [![travis](https://camo.githubusercontent.com/ef8ded1e45dd79c92e1ae244b015528d32476e37edeb6bdf9cdfee3943ee7a69/68747470733a2f2f6170692e7472617669732d63692e636f6d2f6c617a7977652f6c617a792d746f6f6c732e7376673f746f6b656e3d38774b4b706a72643431757a53555a4d535a6f79266272616e63683d6d6173746572)](https://travis-ci.com/lazywe/lazy-tools)

Requirement
===========

[](#requirement)

- php &gt;= 5.3
- Composer
- phpseclib/phpseclib

Installation
============

[](#installation)

first
-----

[](#first)

- composer.json 中新增如下

```
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/lazywe/lazy-tools"
        }
    ],

```

```
    composer require lazywe/lazy-tools -vvv
```

Second
------

[](#second)

- 加载配置

```
    php artisan vendor:publish --provider='Lazy\Tools\ServiceProvider'
```

Third
-----

[](#third)

基础函数
====

[](#基础函数)

```
json(Code $status, string $msg, array $data);
```

密文模式
====

[](#密文模式)

- 密文模式解密需要全局中间件 “lazy-decryption”
- 密文模式需要 env中新增如下

```
    CIPHER=true #是否启用数据加密，客户端需要支持, 默认关闭

    AES_KEY=84283F8F0E36BB7C4F360E068D923DFB #32位你的秘钥

    ORIGINAL_DEBUG=false #是否需要显示原文

    RSA_PUBLIC_KEY_PATH=public.key #系统加密的公钥 storage目录下

    RSA_PRIVATE_KEY_PATH=private.key #客户端提供解密的私钥 storage目录下
```

#### 请求

[](#请求)

- 接收的 **请求参数** 有两个 一个是 “d” 一个是 “e”, 分别都是加密的16进制的数据
- "d" 是rsa加密的部分
- "e" 是aes加密的部分

#### 返回

[](#返回)

- **返回参数** 有三个
- 一个是 “d” 一个是 “e”, 一个是 “f”
- “d”和“e”分别都是加密的16进制的数据
- “f”需要 ORIGINAL\_DEBUG=true 的时候才能输出，调试的时候使用
- "d" 是rsa加密的部分
- "e" 是aes加密的部分

#### 栗子

[](#栗子)

```
    // Usage 前端部分，拿JavaScript为例，
    var params = {
        "username":"lazy",
        "password":"123456",
    };
    var data = {
        d:"rsa加密后得16进制的数据",
        e:"aes使用rsa加密的秘钥将{params}加密后的16进制的数据"
    }
    $.ajax({
        "url":"test",
        "type":"post",
        "timeout":3,
        data:data,
        success:(e){
            console.log(e);
            var key = "rsa解密 e.data.d";
            var params = "aes解密 e.data.e 秘钥是key";
            console.log(params.username)
            console.log(params.password)
             // 输出如下
             // lazy
             // 123456
        }
    })
```

- 前端加密解密 js 版本 待定
- 前端加密解密 dart 版本 待定

```
