Oihana Php Masking

maskRandomString.php

Table of Contents

Functions

maskRandomString()  : mixed
Replaces a string value with a random anonymized string.

Functions

maskRandomString()

Replaces a string value with a random anonymized string.

maskRandomString(mixed $value) : mixed

Implements the conventional randomString masker: only string values are modified — any other type (number, boolean, null) is returned unchanged. The replacement keeps the original length (with a minimum of 1).

The replacement is random, not a reversible hash of the input — the goal is anonymization, not byte-compatibility with any external tool.

Parameters
$value : mixed

The original value.

Tags
throws
RandomException
example
use function oihana\masking\maskRandomString;

maskRandomString( 'My Name' ); // e.g. "x7Bqz9a"
maskRandomString( 1234 );      // 1234 (non-string, unchanged)
since
1.0.0
author

Marc Alcaraz

Return values
mixed

The masked string, or the value unchanged when not a string.

On this page

Search results