Class to manage privacy data masking and unmasking.
More...
|
| | mask ($text) |
| | Mask sensitive GDPR data in the query.
|
| |
| | unmask ($jsonString) |
| | Restore real data from a masked string.
|
| |
| | unmaskAiResponse ($text) |
| | Unmasks a string from an AI response, handling cases where the AI might have stripped the [[ and ]] delimiters from a token.
|
| |
|
| | maskCreditCardCallback (array $matches) |
| | Callback function for preg_replace_callback to mask credit cards.
|
| |
| | passesLuhnCheck ($number) |
| | Validates a number string using the Luhn algorithm.
|
| |
| | createToken ($value, $type) |
| | Create a unique token and store the original value in the map.
|
| |
Class to manage privacy data masking and unmasking.
Definition at line 28 of file privacy_guard.class.php.
◆ createToken()
| PrivacyGuard::createToken |
( |
| $value, |
|
|
| $type ) |
|
private |
Create a unique token and store the original value in the map.
- Parameters
-
| string | $value | The original sensitive value. |
| string | $type | The type of data (e.g., 'EMAIL'). |
- Returns
- string The generated token (e.g., [[EMAIL_1]]).
Definition at line 577 of file privacy_guard.class.php.
Referenced by mask(), and maskCreditCardCallback().
◆ mask()
| PrivacyGuard::mask |
( |
| $text | ) |
|
Mask sensitive GDPR data in the query.
This method iterates through a series of patterns to find and replace sensitive data with tokens.
- Parameters
-
| string | $text | The input string containing potentially sensitive data. |
- Returns
- string The masked string with tokens replacing sensitive data.
- Parameters
-
- Returns
- string
- Parameters
-
- Returns
- string
- Parameters
-
- Returns
- string
- Parameters
-
- Returns
- string
- Parameters
-
- Returns
- string
- Parameters
-
- Returns
- string
- Parameters
-
- Returns
- string
- Parameters
-
- Returns
- string
- Parameters
-
- Returns
- string
Definition at line 53 of file privacy_guard.class.php.
References createToken().
◆ maskCreditCardCallback()
| PrivacyGuard::maskCreditCardCallback |
( |
array | $matches | ) |
|
|
private |
Callback function for preg_replace_callback to mask credit cards.
It first validates the number using the Luhn algorithm.
- Parameters
-
| array<int,string> | $matches The regex matches array. |
- Returns
- string The token if valid, otherwise the original string.
Definition at line 487 of file privacy_guard.class.php.
References createToken(), and passesLuhnCheck().
◆ passesLuhnCheck()
| PrivacyGuard::passesLuhnCheck |
( |
| $number | ) |
|
|
private |
Validates a number string using the Luhn algorithm.
- Parameters
-
| string | $number | The number string, can contain spaces or hyphens. |
- Returns
- bool True if the number is valid, false otherwise.
Definition at line 504 of file privacy_guard.class.php.
Referenced by maskCreditCardCallback().
◆ unmask()
| PrivacyGuard::unmask |
( |
| $jsonString | ) |
|
Restore real data from a masked string.
This method is stateful and relies on the map generated by the preceding mask() call.
- Parameters
-
| string | $jsonString | The string containing tokens to be replaced. |
- Returns
- string The unmasked string with original data restored.
Definition at line 467 of file privacy_guard.class.php.
Referenced by unmaskAiResponse().
◆ unmaskAiResponse()
| PrivacyGuard::unmaskAiResponse |
( |
| $text | ) |
|
Unmasks a string from an AI response, handling cases where the AI might have stripped the [[ and ]] delimiters from a token.
- Parameters
-
| string | $text | The string to unmask. |
- Returns
- string The fully unmasked string.
Definition at line 545 of file privacy_guard.class.php.
References unmask().
The documentation for this class was generated from the following file: