MediaWiki  1.28.0
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. More...
 
static generateHex ($chars, $forceStrong=false)
 Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format. More...
 
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. More...
 

Static Protected Member Functions

static singleton ()
 

Detailed Description

Definition at line 29 of file MWCryptRand.php.

Member Function Documentation

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.

Referenced by EncryptedPassword\crypt(), Pbkdf2Password\crypt(), BcryptPassword\crypt(), MediaWiki\Session\Session\setSecret(), MediaWiki\Session\SessionTest\testSecrets(), and EncryptedPassword\update().

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.

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

static MWCryptRand::singleton ( )
staticprotected
Returns
CryptRand

Definition at line 33 of file MWCryptRand.php.

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.

Referenced by Installer\doGenerateKeys().


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