Download the PHP package snowmannunu/mask-cn without Composer
On this page you can find all versions of the php package snowmannunu/mask-cn. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download snowmannunu/mask-cn
More information about snowmannunu/mask-cn
Files in snowmannunu/mask-cn
Download snowmannunu/mask-cn
More information about snowmannunu/mask-cn
Files in snowmannunu/mask-cn
Vendor snowmannunu
Package mask-cn
Short Description 中文本土场景敏感数据脱敏库 - 内置中国手机号/身份证/银行卡/复姓姓名/车牌等规则,开箱即用,Laravel 友好
License MIT
Homepage https://github.com/SnowmanNunu/mask-cn
Package mask-cn
Short Description 中文本土场景敏感数据脱敏库 - 内置中国手机号/身份证/银行卡/复姓姓名/车牌等规则,开箱即用,Laravel 友好
License MIT
Homepage https://github.com/SnowmanNunu/mask-cn
Please rate this library. Is it a good library?
Informations about the package mask-cn
mask-cn
中文本土场景敏感数据脱敏库 - 开箱即用,无需配置
安装
要求:PHP 7.3+ / 8.0+ / 8.1+ / 8.2+ / 8.3+,需要 ext-mbstring。
用法
基础脱敏
证件/机构代码脱敏
地址脱敏
自定义脱敏规则
实现 StrategyInterface 并注册即可使用:
注册后的策略同样支持 Mask::array() 批量脱敏:
数组批量脱敏
长文本智能识别(auto 模式)
Auto 内置识别类型:
| 类型 | 示例 | 说明 |
|---|---|---|
idCard |
110101199003078888 |
18位身份证 |
phone |
13812345678 |
大陆手机号 |
email |
[email protected] |
邮箱 |
plate |
京A12345 |
中国车牌(含新能源) |
taiwanId |
A123456789 |
台湾身份证/居住证 |
hkMoPass |
H12345678 |
港澳回乡证 |
passport |
E12345678 |
护照 |
uscc |
91110105MA00XXXXXX |
统一社会信用代码(18位) |
bankCard |
6222021234567890123 |
银行卡(16-19位) |
全局配置
通过 Config 类可统一设置默认掩码字符,无需在每个调用处重复传入:
优先级: 方法级 options['char'] > Config::get('char') > 默认 *。
PSR-3 Logger 集成
自动在日志输出前脱敏敏感字段,无需改动业务代码:
也可在任意日志框架中使用静态处理器:
自定义掩码字符
所有方法均支持 char 选项:
Laravel 集成
服务提供者已通过 extra.laravel.providers 自动注册,无需手动配置。
也可作为验证规则使用(可选):
支持的验证类型: phone、idCard、email、bankCard、name、plate、uscc、hkMoPass、taiwanId、passport、address。
测试
路线图
- [x] v0.1.x: 基础 6 个 Strategy + Auto 智能识别 + Laravel 集成
- [x] v0.2.x: 统一社会信用代码、组织机构代码、旧版营业执照
- [x] v0.2.x: 港澳通行证/居住证、台湾身份证/居住证、护照
- [x] v0.2.x: 中文地址脱敏
- [x] v0.2.x: Auto 模式支持 char 选项和 JSON 输入
- [x] v0.3.x: 自定义脱敏规则注册
- [x] v1.0.0: 全局配置(Config) + PSR-3 Logger 集成
- [x] v1.1.0: MaskedField 验证规则扩展 + Auto 模式新增证件/车牌/USCC 识别
- [x] v1.2.0: Config 支持按策略配置保留位数 + MaskedField 支持自定义掩码字符校验
License
MIT
All versions of mask-cn with dependencies
PHP Build Version
Package Version
The package snowmannunu/mask-cn contains the following files
Loading the files please wait ...