PHPackages                             klib/wxtools - 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. klib/wxtools

ActiveLibrary

klib/wxtools
============

Make wxchar msg srypto lib.

v1.0.3(5y ago)02.5kMITPHPPHP &gt;=7.0

Since Nov 11Pushed 5y ago1 watchersCompare

[ Source](https://github.com/kami1983/klib-wxtools)[ Packagist](https://packagist.org/packages/klib/wxtools)[ RSS](/packages/klib-wxtools/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (4)Used By (0)

klib-wxtools
============

[](#klib-wxtools)

一个服务于微信开发的类库工具包

安装
==

[](#安装)

- `composer require klib/wxtools` 即可

使用
==

[](#使用)

- 以Larvael 框架举例，修改 `routes/web.php`

```
... 其他代码
# 在头部引用类库
use KLib\WxTools\Crypto\WXBizMsgCrypt;

# 添加测试路由
Route::get('/klib/test', function () {

    // 第三方发送消息给公众平台
    # 创建 WXBizMsgCrypt 类所需要的信息
    $encodingAesKey = "nz47o6NxDrpf4hXPoDzXUZMCYR4hhnUBB4dKR4RuJ4u";
    $token = "JWKFKKKEQBBDKFKS";
    $appId = "wxd3e6d25996c4bc5f";

    # 浏览器发送的消息
    $timeStamp = "1409304348";
    $nonce = "xxxxxx";

    # 待解密的消息
    $text = "1407743423";

    $pc = new WXBizMsgCrypt($token, $encodingAesKey, $appId);
    $encryptMsg = '';
    $errCode = $pc->encryptMsg($text, $timeStamp, $nonce, $encryptMsg);
    if ($errCode == 0) {
        print("加密后: " . $encryptMsg . "\n");
    } else {
        print($errCode . "\n");
    }

    $xml_tree = new \DOMDocument();
    $xml_tree->loadXML($encryptMsg);
    $array_e = $xml_tree->getElementsByTagName('Encrypt');
    $array_s = $xml_tree->getElementsByTagName('MsgSignature');
    $encrypt = $array_e->item(0)->nodeValue;
    $msg_sign = $array_s->item(0)->nodeValue;

    $format = "";
    $from_xml = sprintf($format, $encrypt);

    // 第三方收到公众号平台发送的消息
    $msg = '';
    $errCode = $pc->decryptMsg($msg_sign, $timeStamp, $nonce, $from_xml, $msg);
    if ($errCode == 0) {
        print("解密后: " . $msg . "\n");
    } else {
        print("出错 ：".$errCode . "\n");
    }

});

```

- 浏览器访问： `http://测试域名/klib/test` 后查看源码，加密解密成功，之后自己配置自己的信息即可。

###  Health Score

26

—

LowBetter than 46% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~0 days

Total

3

Last Release

1957d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ccdaf004bf6e38ff14bf4711002f1507f3f5d1fd172e7cdb1fb458a21970375e?d=identicon)[kami1983](/maintainers/kami1983)

---

Top Contributors

[![kami1983](https://avatars.githubusercontent.com/u/8407663?v=4)](https://github.com/kami1983 "kami1983 (6 commits)")

### Embed Badge

![Health badge](/badges/klib-wxtools/health.svg)

```
[![Health](https://phpackages.com/badges/klib-wxtools/health.svg)](https://phpackages.com/packages/klib-wxtools)
```

PHPackages © 2026

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