MediaWiki  1.32.5
CryptRand Class Reference

Public Member Functions

 generate ( $bytes)
 Generate a run of cryptographically random data and return it in raw binary form. More...
 
 generateHex ( $chars)
 Generate a run of cryptographically random data and return it in hexadecimal string format. More...
 
 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...
 

Public Attributes

const MIN_ITERATIONS = 1000
 
const MSEC_PER_BYTE = 0.5
 

Protected Member Functions

 driftHash ( $data)
 Randomly hash data while mixing in clock drift data for randomness. More...
 
 initialRandomState ()
 Initialize an initial random state based off of whatever we can find. More...
 
 randomState ()
 Return a rolling random state initially build using data from unstable sources. More...
 

Detailed Description

Deprecated:
since 1.32, use random_bytes()/random_int()

Definition at line 30 of file CryptRand.php.

Member Function Documentation

◆ driftHash()

CryptRand::driftHash (   $data)
protected

Randomly hash data while mixing in clock drift data for randomness.

Deprecated:
since 1.32, unused and does nothing
Parameters
string$dataThe data to randomly hash.
Returns
string The hashed bytes
Author
Tim Starling

Definition at line 61 of file CryptRand.php.

◆ generate()

CryptRand::generate (   $bytes)

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

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

Parameters
int$bytesThe number of bytes of random data to generate
Returns
string Raw binary random data

Definition at line 98 of file CryptRand.php.

◆ generateHex()

CryptRand::generateHex (   $chars)

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

Parameters
int$charsThe number of hex chars of random data to generate
Returns
string Hexadecimal random data

Definition at line 110 of file CryptRand.php.

References MWCryptRand\generateHex().

◆ initialRandomState()

CryptRand::initialRandomState ( )
protected

Initialize an initial random state based off of whatever we can find.

Deprecated:
since 1.32, unused and does nothing
Returns
string

Definition at line 48 of file CryptRand.php.

◆ randomState()

CryptRand::randomState ( )
protected

Return a rolling random state initially build using data from unstable sources.

Deprecated:
since 1.32, unused and does nothing
Returns
string A new weak random state

Definition at line 72 of file CryptRand.php.

◆ wasStrong()

CryptRand::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.

Deprecated:
since 1.32, always returns true
Returns
bool Always true

Definition at line 85 of file CryptRand.php.

Member Data Documentation

◆ MIN_ITERATIONS

const CryptRand::MIN_ITERATIONS = 1000
Deprecated:
since 1.32, unused

Definition at line 34 of file CryptRand.php.

◆ MSEC_PER_BYTE

const CryptRand::MSEC_PER_BYTE = 0.5
Deprecated:
since 1.32, unused

Definition at line 39 of file CryptRand.php.


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