MediaWiki  master
MediaWiki\User\TempUser\ScrambleMapping Class Reference

A mapping which converts sequential input into an output sequence that looks pseudo-random, but preserves the base-10 length of the input number. More...

Inheritance diagram for MediaWiki\User\TempUser\ScrambleMapping:
Collaboration diagram for MediaWiki\User\TempUser\ScrambleMapping:

## Public Member Functions

__construct ( \$config)

getSerialIdForIndex (int \$index)

## Detailed Description

A mapping which converts sequential input into an output sequence that looks pseudo-random, but preserves the base-10 length of the input number.

Take a sequence generated by multiplying the previous element of the sequence by a fixed number "g", then applying the modulus "p":

X(0) = 1 X(i) = ( g X(i-1) ) mod p

If g is a primitive root modulo p, then this sequence will cover all values from 1 to p-1 before it repeats. X(i) is a modular exponential function (g^i mod p) and algorithms are available to calculate it efficiently.

Loosely speaking, we choose a sequence based on the number of digits N in the input, with the period being approximately 10^N, so that the number of digits in the output will be approximately the same.

More precisely, after offsetting the subsequent sequences to avoid colliding with the previous sequences, the period ends up being about 0.9 * 10^N

The modulo p is always a prime number because that makes the maths easier. We use a value for g close to p/sqrt(3) since that seems to stir the digits better than the largest or smallest primitive root.

Access: internal

Definition at line 32 of file ScrambleMapping.php.

## ◆ __construct()

 MediaWiki\User\TempUser\ScrambleMapping::__construct ( \$config )

Definition at line 65 of file ScrambleMapping.php.

## ◆ getSerialIdForIndex()

 MediaWiki\User\TempUser\ScrambleMapping::getSerialIdForIndex ( int \$index )
Parameters
 int \$index
Returns
string The serial ID. This should consist of title characters but should not be a single asterisk.

Implements MediaWiki\User\TempUser\SerialMapping.

Definition at line 74 of file ScrambleMapping.php.

The documentation for this class was generated from the following file: