MediaWiki REL1_28
MWCryptRand Class Reference

Static Public Member Functions

static generate ( $bytes, $forceStrong=false)
 Generate a run of (ideally) cryptographically random data and return it in raw binary form.
 
static generateHex ( $chars, $forceStrong=false)
 Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format.
 
static wasStrong ()
 Return a boolean indicating whether or not the source used for cryptographic random bytes generation in the previously run generate* call was cryptographically strong.
 

Static Protected Member Functions

static singleton ()
 

Detailed Description

Definition at line 29 of file MWCryptRand.php.

Member Function Documentation

◆ generate()

static MWCryptRand::generate (   $bytes,
  $forceStrong = false 
)
static

Generate a run of (ideally) cryptographically random data and return it in raw binary form.

You can use MWCryptRand::wasStrong() if you wish to know if the source used was cryptographically strong.

Parameters
int$bytesThe number of bytes of random data to generate
bool$forceStrongPass true if you want generate to prefer cryptographically strong sources of entropy even if reading from them may steal more entropy from the system than optimal.
Returns
string Raw binary random data

Definition at line 60 of file MWCryptRand.php.

References singleton().

Referenced by BcryptPassword\crypt(), EncryptedPassword\crypt(), Pbkdf2Password\crypt(), and EncryptedPassword\update().

◆ generateHex()

static MWCryptRand::generateHex (   $chars,
  $forceStrong = false 
)
static

Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format.

You can use MWCryptRand::wasStrong() if you wish to know if the source used was cryptographically strong.

Parameters
int$charsThe number of hex chars of random data to generate
bool$forceStrongPass true if you want generate to prefer cryptographically strong sources of entropy even if reading from them may steal more entropy from the system than optimal.
Returns
string Hexadecimal random data

Definition at line 76 of file MWCryptRand.php.

References singleton().

Referenced by UIDGenerator\__construct(), User\confirmationToken(), MWSaltedPassword\crypt(), Installer\doGenerateKeys(), PasswordFactory\generateRandomPasswordString(), MediaWiki\Session\SessionManager\generateSessionId(), Pingback\getOrCreatePingbackId(), User\getToken(), AuthManagerSpecialPage\handleReauthBeforeExecute(), UIDGenerator\newUUIDv4(), User\resetTokenFromOption(), BotPassword\save(), User\setToken(), and ApiRevisionDeleteTest\setUp().

◆ singleton()

static MWCryptRand::singleton ( )
staticprotected
Returns
CryptRand

Definition at line 33 of file MWCryptRand.php.

Referenced by generate(), generateHex(), and wasStrong().

◆ wasStrong()

static MWCryptRand::wasStrong ( )
static

Return a boolean indicating whether or not the source used for cryptographic random bytes generation in the previously run generate* call was cryptographically strong.

Returns
bool Returns true if the source was strong, false if not.

Definition at line 44 of file MWCryptRand.php.

References singleton().

Referenced by Installer\doGenerateKeys().


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