1. Go to this page and download the library: Download gbhorwood/redactem 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/ */
/**
* A function to test if a key/value pair should be redacted
* Here, if the key is equal to 'secret' and the value is only digits.
* @param String|Int $k The key of a key/value pair
* @param String|Int $v The value of a key/value pair
* @return bool
*/
$shouldRedact = fn ($k, $v) => (bool)($k == 'secret' && preg_match('/^[0-9]*$/', (string)$v));
/**
* A function to build the redaction text for a value
* Here, a string of exclamation marks the length of the string being redacted
* @param String|Int $v The value of a key/value pair
* @return String
*/
$redactionText = fn ($v) => join(array_fill(0, strlen((string)$v), '!'));
$redactedJson = Redact::redact($originalJson, $shouldRedact, $redactionText);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.