PHP code example of az13js / desensitization

1. Go to this page and download the library: Download az13js/desensitization library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

az13js / desensitization example snippets




\Desensitization\Filter::config([
    'ion(&$input) { $input = '**'; },
    ],
]);

return \Desensitization\Filter::response([
    'mobile' => '13699999999',
    'name' => '玉皇大帝1',
    'sub' => [
        'mobile' => '13699999998',
        'name' => '玉皇大帝2',
    ],
]);



\Desensitization\Filter::config([
    '    'sub.name' => function(&$input) { $input = '**'; },
    ],
]);

return \Desensitization\Filter::response([
    'mobile' => '13699999999',
    'name' => '玉皇大帝1',
    'sub' => [
        'mobile' => '13699999998',
        'name' => '玉皇大帝2',
    ],
]);



class Foo {
    public $name = '玉皇大帝';
    public $mobile = '13699999999';
    private $h = 'nothing';
}

\Desensitization\Filter::config([
    '

\Desensitization\Filter::config([
    'uri' => '/local/test',
    // ...
]);

\Desensitization\Filter::config([
    'uri' => null,
    // ...
]);

\Desensitization\Filter::config([
    'ction(&$input) { $input = '**'; },
    ],
]);

return \Desensitization\Filter::response($yourResponse, '/user/info');

\Desensitization\Filter::config([
    '



\Desensitization\Filter::config([
    '            'mask' => [
                'left' => 3,
                'right' => 3,
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '1234567890',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'left' => 0.2,
                'right' => 0.2,
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '12345678901234567890',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'left' => [0.5249, 'ceil'],
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '12345678901234567890',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'left' => 0.2,
                'right' => 0.2,
                'reverse' => true,
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '12345678901234567890',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'left' => 0.5,
                'symbol' => '?',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '12345678901234567890',
]);

Filter::config([
    '    'example' => [
            'mask' => [
                'type' => 'mobile',
            ],
        ],
    ],
]);

Filter::config([
    '    'example' => 'mobile', // 对example属性应用手机号码掩盖规则
    ],
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'credential',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '1234567890',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'idcard',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '123456789012345678',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'bank',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '123456789012345678',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'netaccount',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '123456789012345678',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'ip',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '127.0.0.1',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'mobile',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '13600000000',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'telephone',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '(010)66666666',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'name',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '周杰伦',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'plate',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '1234567890',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'email',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '[email protected]',
]);



\Desensitization\Filter::config([
    '            'mask' => [
                'type' => 'address',
            ],
        ],
    ],
]);

return \Desensitization\Filter::response([
    'example' => '胶州市胶北镇玉皇庙村东',
]);



use \Desensitization\Filter as Filter;
use \Desensitization\Types as Types;

Filter::config([
    '     [
            '    [
            '::response([
    'name' => '周杰伦',
    'name1' => '周杰伦',
    'name2' => '周杰伦',
], '/a');

$b = Filter::response([
    'name' => '周杰伦',
    'name1' => '周杰伦',
    'name2' => '周杰伦',
], '/b');

$c = Filter::response([
    'name' => '周杰伦',
    'name1' => '周杰伦',
    'name2' => '周杰伦',
], '/c');

var_dump($a, $b, $c);



\Desensitization\Filter::config([
    '',
    ],
    'before' => function(&$data) { $data['backup'] = $data['name']; },
    'after' => function(&$data) { $data['note'] = "before: {$data['backup']}, after: {$data['name']}"; },
]);

return \Desensitization\Filter::response([
    'name' => '周杰伦',
]);

\Desensitization\Filter::config([
    'me',
    ],
    'before' => function(&$data) { $data['backup'] = $data['name']; },
    'after' => function(&$data) { $data['note'] = "before: {$data['backup']}, after: {$data['name']}"; },
]);

// 撤销配置
\Desensitization\Filter::config([
    'before' => null,
    'after' => null,
]);
vendor/autoload.php
/user
/user