class vB_Utility_Random

Traits

Methods

__sleep()

No description

__wakeup()

No description

string
alphanumeric(integer $length)

Generates a random string of alphanumeric characters

string($characters, $length)

Generate a randon string from a given alphabet

hex(integer $length = 32)

Approximation of old fetch_random_string() function in terms of output set, not distribution.

string
vbhash(integer $length = 32)

vBulletin's hash fetcher, note this may change from a-f0-9 to a-z0-9 in future.

string
nonsecureAlphanumeric(integer $length)

Generates a random string of alphanumeric characters. Exactly like alphanumeric but uses a random number generator that is not cryptographically secure.

nonsecureString($characters, $length)

This is the same as string, but uses a random generator that is not cryptographically secure

Details

__sleep()

__wakeup()

at line 23
string alphanumeric(integer $length)

Generates a random string of alphanumeric characters

Calls the string function with an alphabet of lower case and upper case latin characters and numbers

Parameters

integer $length

Return Value

string -- random string of length $length

at line 36
string($characters, $length)

Generate a randon string from a given alphabet

Parameters

$characters
$length

at line 72
hex(integer $length = 32)

Approximation of old fetch_random_string() function in terms of output set, not distribution.

Parameters

integer $length Length of desired hash

at line 122
string vbhash(integer $length = 32)

vBulletin's hash fetcher, note this may change from a-f0-9 to a-z0-9 in future.

Note that the caller should not depend on format of the returned string other then it should be printable. If a hex string is specificially needed, call the hex function.

Parameters

integer $length Length of desired hash

Return Value

string

at line 138
string nonsecureAlphanumeric(integer $length)

Generates a random string of alphanumeric characters. Exactly like alphanumeric but uses a random number generator that is not cryptographically secure.

Calls the nonsecureString function with an alphabet of lower case and upper case latin characters and numbers

Parameters

integer $length

Return Value

string -- random string of length $length

at line 157
nonsecureString($characters, $length)

This is the same as string, but uses a random generator that is not cryptographically secure

This function is faster than string and does not use up "entropy" in the secure random number generater. Therefore it's preferred for uses that don't require cryptographic security (for example, unique identifiers that are entirely internal and therefore can't be guessed/spoofed or situations where we validate security in other ways -- such as were the id will only be accepted from a validated user account where we've already told the user what the id is).

Parameters

$characters
$length