Laravel 数据库脱敏工具,仅支持 MySQL
github:https://github.com/y-ui/laravel-data-maski...
支持使用任意字符替换:
'name' => '' nothing to do
'name' => '*:1-' Tom => *** Replace all characters
'name' => '0:2-4' William => W000iam
'name' => '0:3-5' Tom => To000
'phone' => '*:4-7' 18666666666 => 186****6666
'phone' => '123:4-' 18666666666 => 18612312312
'phone' => '*:1~2' 18666666666 => 1********66 Keep the first and end character
*:2-5
表示用号替换第2到第5个字符,如果字符串小于5个字符,用号补全,*
可以用其他字符替换,且不限于一个字符*:2~2
表示字符串前后各保留2个字符,其他的用*号替换
邮箱格式替换
'email' => 'email:3-' production@google.com => pr********@google.com Replace only the characters before @
只替换@符之前的字符,数字区间规则同上
使用faker生成假数据替换
'address' => 'faker:address'
'date' => "faker:date($format = 'Y-m-d', $max = 'now')"
'name' => 'faker:name'
这种方法较慢,需要一行行更新
欢迎大家使用、提建议、提PR
本作品采用《CC 协议》,转载必须注明作者和本文链接
github上是刚刚提交的啊~