Home  >  Article  >  Backend Development  >  Mask sensitive data using PHP Masked Package

Mask sensitive data using PHP Masked Package

藏色散人
藏色散人forward
2019-09-30 14:36:012655browse

Fuko \ Masked is a small PHP library by Kaloyan Tsvetkov for masking sensitive data by replacing blacklisted elements with edited ones.

The following is a basic usage example of the package readme :

use Fuko\Masked\Protect;
//隐藏$secret_key var中的值
Protect::hideValue($secret_key);
//隐藏$ _POST['password'] 的值
Protect::hideInput('password', INPUT_POST);
$redacted = Protect::protect($_POST);

Based on the above call, blacklisted values ​​and inputs will be blocked. Another example of a readme file is a debug blacklist, similar to Laravel 5's Whoops blacklist:

use \Fuko\Masked\Protect;
Protect::hideInputs(array(
    INPUT_ENV => array(
        'APP_KEY',
        'DB_PASSWORD',
        'REDIS_PASSWORD',
        'MAIL_PASSWORD',
        'PUSHER_APP_KEY',
        'PUSHER_APP_SECRET',
        ),
    INPUT_SERVER => array(
        'PHP_AUTH_PW',
        'APP_KEY',
        'DB_PASSWORD',
        'REDIS_PASSWORD',
        'MAIL_PASSWORD',
        'PUSHER_APP_KEY',
        'PUSHER_APP_SECRET',
        ),
    INPUT_POST => array(
        'password',
        )
    )
);
//传递信息 `\Fuko\Masked\Protect::protect()`
//将隐藏列入黑名单的输入
\Fuko\Masked\Protect::protect($_POST);

Check out the readme file for more examples, including Custom blocking rules. You can learn more about this package at fuko-php/masked , get complete installation instructions and view the source code on GitHub.

For more PHP knowledge, please visit PHP Chinese website!

The above is the detailed content of Mask sensitive data using PHP Masked Package. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete