PHPackages                             xy\_jx/utils - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. xy\_jx/utils

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

xy\_jx/utils
============

utils🛠一个工具箱

0.8.13(2mo ago)71.5k—0%3MITPHPPHP &gt;=7.3.0

Since Aug 3Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/XY-JX/utils)[ Packagist](https://packagist.org/packages/xy_jx/utils)[ RSS](/packages/xy-jx-utils/feed)WikiDiscussions master Synced 1mo ago

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

工具插件
====

[](#工具插件)

[![Latest Stable Version](https://camo.githubusercontent.com/b4690955ae20e84fdc8a6a4093432d171ea8cdb23c12ab494c441328246e177e/687474703a2f2f706f7365722e707567782e6f72672f78795f6a782f7574696c732f76)](https://packagist.org/packages/xy_jx/utils)[![Total Downloads](https://camo.githubusercontent.com/d927645b4cb5f1f94d2a7b8654abcfb8f64c3080f84674d55a8e56d17913339e/687474703a2f2f706f7365722e707567782e6f72672f78795f6a782f7574696c732f646f776e6c6f616473)](https://packagist.org/packages/xy_jx/utils)[![Latest Unstable Version](https://camo.githubusercontent.com/247419629667345bcf607089d67ac7fdac30f1534cb3eae6818c9376e7aa716a/687474703a2f2f706f7365722e707567782e6f72672f78795f6a782f7574696c732f762f756e737461626c65)](https://packagist.org/packages/xy_jx/utils)[![License](https://camo.githubusercontent.com/24cae1da06e3b4244d32ec388de822b106fe3318677db73cf5ce15268ec9a667/687474703a2f2f706f7365722e707567782e6f72672f78795f6a782f7574696c732f6c6963656e7365)](https://packagist.org/packages/xy_jx/utils)[![PHP Version Require](https://camo.githubusercontent.com/5ea744593f6d334962d8caae3da7977f56acb151eeb2a6ab0a8ba64e0b97b734/687474703a2f2f706f7365722e707567782e6f72672f78795f6a782f7574696c732f726571756972652f706870)](https://packagist.org/packages/xy_jx/utils)

1.生成二维码 2.xml与数组转换 3.生成范围经纬度 4.经纬度换算距离 5.人民币转大写 6.MurmurHash 7.GoogleAuth 8.对称加密和证书加密 9.访问限制 10.生成证书 11.验证码 12.Excel导出 13.jwt

### 第一步：composer安装

[](#第一步composer安装)

```
 composer require xy_jx/utils

```

### 第二步使用：

[](#第二步使用)

#### 获取随机字符串

[](#获取随机字符串)

```
     echo  rand_string();//KPV1

```

#### 获取UUID

[](#获取uuid)

```
      echo  UUID();//0b90f8b2-dca8-4ee8-86a1-f2a990605912

```

#### 数字人民币转汉字大写

[](#数字人民币转汉字大写)

```
      echo  rmb_capital(159622);//壹拾伍万玖仟陆佰贰拾贰圆

```

#### 验证码

[](#验证码)

```
use xy_jx\Utils\Captcha;
class xy
{
        // 初始化验证码类
        $Captcha = new Captcha();
        // 生成验证码和key  （密钥没有存储到session或Cookie）可自己存储 防止用户重复使用
        $cap = $Captcha->create();
        //echo $cap['img'];//data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAA+CAMAAABZTaSoAAAAclBMVEXOvPAKZhygpcukoLrfprXhuaOenLe+n8ianayatMa...
        // 验证是否正确
        var_dump($Captcha->check($cap['code'], $cap['key']));// true
}

```

#### jwt

[](#jwt)

```
use xy_jx\Utils\Jwt;
class xy
{
        //设置额外的密钥
        Jwt::set('iv', '@user@token@jwt*');
        Jwt::set('key', '@user@token@jwt*');//默认key 0.8+
        $user  = [
            'id'        => 5,
            'tel'       => '188888888888',
            'name'      => 'xy',
            'email'     => 'xy@email.com',
            'sex'       => 2,
            'login_num' => 12,
        ];
        //获取token
        $token = Jwt::getToken($user);
        //通过token获取用户数据
        $user  = Jwt::getUser($token['token']);
        var_dump($user);
}

```

#### 加解密数据

[](#加解密数据)

```
use xy_jx\Utils\Encryption;
class xy
{
        $data = [
            'id'        => 5,
            'tel'       => '188888888888',
            'name'      => 'xy',
            'email'     => 'xy@email.com',
            'sex'       => 2,
            'login_num' => 12,
        ];
        //加密数据
        $encrypt = Encryption::Encrypt($data);
        //解密数据
        var_dump(Encryption::Decrypt($encrypt));
}

```

#### 谷歌验证码GoogleAuthenticator

[](#谷歌验证码googleauthenticator)

```
use xy_jx\Utils\GoogleAuthenticator;
class xy
{
        //创建一个密钥
        $secret = GoogleAuthenticator::createSecret();//WQI5IOGD6WSRHDIFNFHYJCHANUJZDMAG
        //通过密钥获取一个验证码
        $code = GoogleAuthenticator::getCode($secret);//273079
        //通过密钥验证code
        var_dump(GoogleAuthenticator::verifyCode($secret, $code));// true
        //获取第3方绑定二维码（从google图表中获取图像的QR码URL）
        echo GoogleAuthenticator::getQRCodeGoogleUrl(
            $name = 'xy',
            $secret,
            $title = '绑定密钥'
        );//https://api.qrserver.com/v1/create-qr-code/?data=otpauth%3A%2F%2Ftotp%2Fxy%3Fsecret%3DG3HVLCM5OCO6GTLCVNTD35UFIO4L6GB3%26issuer%3D%25E7%25BB%2591%25E5%25AE%259A%25E5%25AF%2586%25E9%2592%25A5&size=200x200&ecc=M

}

```

#### Excel导出

[](#excel导出)

##### 额外安装phpspreadsheet

[](#额外安装phpspreadsheet)

```
composer require phpoffice/phpspreadsheet

```

```
use xy_jx\Utils\Excel;
class xy
{
        $userAll = [
            [
                'id'   => 1,
                'name' => '张三',
                'cd'   => date('Y-m-d'),
            ],
            [
                'id'   => 2,
                'name' => '李四',
                'cd'   => date('Y-m-d'),
            ],
            [
                'id'   => 3,
                'name' => '王五',
                'cd'   => date('Y-m-d'),
            ],
        ];

        Excel::header('用户导出', ['id' => 'ID', 'name' => '名字', 'cd' => '时间'])
            ->content($userAll)->save('Xlsx', true, '用户.Xlsx');
}

```

#### 其他方法使用也如此（很简单可自行查看代码都有注释）

[](#其他方法使用也如此很简单可自行查看代码都有注释)

#### 有什么建议和意见，可通过issue或邮箱反馈

[](#有什么建议和意见可通过issue或邮箱反馈)

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance87

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Recently: every ~179 days

Total

94

Last Release

63d ago

PHP version history (2 changes)0.1PHP &gt;=7.1.0

0.3.1PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/73cafb51412d52685ea85aac0862793fb6ab965e19c0c59e3a098807803289f4?d=identicon)[xy](/maintainers/xy)

---

Top Contributors

[![XY-JX](https://avatars.githubusercontent.com/u/57987232?v=4)](https://github.com/XY-JX "XY-JX (124 commits)")

---

Tags

captchaencryptionexcelgoogleauthjwtphputils

### Embed Badge

![Health badge](/badges/xy-jx-utils/health.svg)

```
[![Health](https://phpackages.com/badges/xy-jx-utils/health.svg)](https://phpackages.com/packages/xy-jx-utils)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
