Oihana Php Masking

maskXifyFront.php

Table of Contents

Functions

maskXifyFront()  : mixed
Masks the front of each word with `x`, keeping a few trailing characters.

Functions

maskXifyFront()

Masks the front of each word with `x`, keeping a few trailing characters.

maskXifyFront(mixed $value[, int $unmaskedLength = 2 ][, bool $hash = false ][, int $seed = 0 ]) : mixed

Implements the conventional xifyFront masker. Within each word (a run of alphanumeric, _ or - characters) every character except the last unmaskedLength ones is replaced by x; words no longer than unmaskedLength are left untouched. Every other character (spaces, punctuation) becomes a blank. Non-string values (boolean, number) become the fixed string "xxxx", and null stays null.

Parameters
$value : mixed

The original value.

$unmaskedLength : int = 2

How many trailing characters of each word to keep.

$hash : bool = false

Append a short hash to reduce collisions.

$seed : int = 0

Secret used by the hash (0 = unseeded).

Tags
example
use function oihana\masking\maskXifyFront;

maskXifyFront( 'This is a test!Do you agree?' ); // "xxis is a xxst Do xou xxxee "
maskXifyFront( true );                           // "xxxx"
maskXifyFront( null );                           // null
maskXifyFront( 'secret' , 4 );                   // "xxcret"
since
1.0.0
author

Marc Alcaraz

Return values
mixed

The masked string, "xxxx" for non-strings, or null.

On this page

Search results