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

Mask sensitive data using PHP Masked Package

藏色散人
Release: 2023-04-07 13:58:01
forward
2711 people have browsed it

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);
Copy after login

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);
Copy after login

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!

Related labels:
php
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template