PHPackages                             wuwx/laravel-hashing-sm3 - 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. wuwx/laravel-hashing-sm3

ActiveLibrary[Security](/categories/security)

wuwx/laravel-hashing-sm3
========================

v2.4.0(1mo ago)318MITPHPPHP ^7.3|^8.0CI passing

Since Oct 3Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/wuwx/laravel-hashing-sm3)[ Packagist](https://packagist.org/packages/wuwx/laravel-hashing-sm3)[ RSS](/packages/wuwx-laravel-hashing-sm3/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (7)Dependencies (8)Versions (8)Used By (0)

Laravel Hashing SM3
===================

[](#laravel-hashing-sm3)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

为 Laravel 框架提供 SM3 国密哈希算法支持。

特性
--

[](#特性)

- 🔐 支持 SM3 国密哈希算法
- 🚀 无缝集成 Laravel Hashing 系统
- ✅ 完全兼容 Laravel 5.6 - 13.x
- 📦 自动服务提供者注册
- 🧪 包含完整的单元测试

系统要求
----

[](#系统要求)

- PHP &gt;= 7.3
- Laravel &gt;= 5.6（支持到 13.x）

安装
--

[](#安装)

使用 Composer 安装：

```
composer require wuwx/laravel-hashing-sm3
```

Laravel 5.5+ 会自动注册服务提供者，无需手动配置。

配置
--

[](#配置)

### 方式一：设置为默认驱动

[](#方式一设置为默认驱动)

编辑 `config/hashing.php` 文件，将 `driver` 更改为 `sm3`：

```
'driver' => 'sm3',
```

### 方式二：按需使用

[](#方式二按需使用)

保持默认驱动不变，在需要时指定使用 SM3：

```
Hash::driver('sm3')->make($value);
```

使用示例
----

[](#使用示例)

### 生成哈希值

[](#生成哈希值)

```
use Illuminate\Support\Facades\Hash;

// 使用默认驱动（需先配置为 sm3）
$hash = Hash::make('password');

// 或显式指定 sm3 驱动
$hash = Hash::driver('sm3')->make('password');
```

### 验证哈希值

[](#验证哈希值)

```
// 验证密码
if (Hash::check('password', $hash)) {
    // 密码正确
}

// 使用 sm3 驱动验证
if (Hash::driver('sm3')->check('password', $hash)) {
    // 密码正确
}
```

### 在用户认证中使用

[](#在用户认证中使用)

配置为默认驱动后，Laravel 的用户认证系统会自动使用 SM3 算法：

```
// 用户注册
$user = User::create([
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'password' => Hash::make('secret'), // 自动使用 SM3
]);

// 用户登录验证
if (Hash::check($request->password, $user->password)) {
    // 登录成功
}
```

测试
--

[](#测试)

运行测试套件：

```
composer test
```

或使用 PHPUnit：

```
vendor/bin/phpunit
```

依赖
--

[](#依赖)

本包使用 [ch4o5/sm3-php](https://github.com/ch4o5/sm3-php) 作为底层 SM3 算法实现。

许可证
---

[](#许可证)

本项目采用 MIT 许可证。详见 [LICENSE](LICENSE) 文件。

贡献
--

[](#贡献)

欢迎提交 Issue 和 Pull Request！

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance90

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Recently: every ~308 days

Total

7

Last Release

51d ago

Major Versions

v0.1.0 → v1.0.02020-10-03

v1.0.0 → v2.0.02022-11-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c1977bba4586c70a4bdb6faaee4823184904ff3bd3246e79069871465500611?d=identicon)[wuwx](/maintainers/wuwx)

---

Top Contributors

[![wuwx](https://avatars.githubusercontent.com/u/4401?v=4)](https://github.com/wuwx "wuwx (17 commits)")

---

Tags

laravelhashingsm3hasher

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wuwx-laravel-hashing-sm3/health.svg)

```
[![Health](https://phpackages.com/badges/wuwx-laravel-hashing-sm3/health.svg)](https://phpackages.com/packages/wuwx-laravel-hashing-sm3)
```

###  Alternatives

[mikemclin/laravel-wp-password

Laravel package that checks and creates WordPress password hashes

863.4M2](/packages/mikemclin-laravel-wp-password)[tzsk/otp

A secure, database-free One-Time Password (OTP) generator and verifier for PHP and Laravel.

241641.4k1](/packages/tzsk-otp)[ammardev/laravel-wp-hash-driver

Supports Wordpress passwords hashing and checking in Laravel's Hash facade.

169.3k](/packages/ammardev-laravel-wp-hash-driver)[laragear/poke

Keep your forms alive, avoid TokenMismatchException by gently poking your Laravel app

2211.5k](/packages/laragear-poke)[robclancy/laravel4-hashing

Package for when you can't use Bcrypt in Laravel 4.

301.8k1](/packages/robclancy-laravel4-hashing)

PHPackages © 2026

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