vB_Utility_Random
in package
Uses
vB_Utility_Trait_NoSerialize
Table of Contents
- $alphanum : mixed
- __serialize() : mixed
- __sleep() : mixed
- __unserialize() : mixed
- __wakeup() : mixed
- alphanumeric() : string
- Generates a random string of alphanumeric characters
- hex() : mixed
- Approximation of old fetch_random_string() function in terms of output set, not distribution.
- nonsecureAlphanumeric() : string
- Generates a random string of alphanumeric characters. Exactly like alphanumeric but uses a random number generator that is not cryptographically secure.
- nonsecureString() : mixed
- This is the same as string, but uses a random generator that is not cryptographically secure
- string() : mixed
- Generate a randon string from a given alphabet
- vbhash() : string
- vBulletin's hash fetcher, note this may change from a-f0-9 to a-z0-9 in future.
Properties
$alphanum
private
static mixed
$alphanum
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . 'abcdefghijklmnopqrstuvwxyz' . '0123456789'
Methods
__serialize()
public
__serialize() : mixed
Return values
mixed —__sleep()
public
__sleep() : mixed
Return values
mixed —__unserialize()
public
__unserialize(mixed $serialized) : mixed
Parameters
- $serialized : mixed
Return values
mixed —__wakeup()
public
__wakeup() : mixed
Return values
mixed —alphanumeric()
Generates a random string of alphanumeric characters
public
alphanumeric(int $length) : string
Calls the string function with an alphabet of lower case and upper case latin characters and numbers
Parameters
- $length : int
Return values
string —-- random string of length $length
hex()
Approximation of old fetch_random_string() function in terms of output set, not distribution.
public
hex([mixed $length = 32 ]) : mixed
Parameters
- $length : mixed = 32
Return values
mixed —nonsecureAlphanumeric()
Generates a random string of alphanumeric characters. Exactly like alphanumeric but uses a random number generator that is not cryptographically secure.
public
nonsecureAlphanumeric(int $length) : string
Calls the nonsecureString function with an alphabet of lower case and upper case latin characters and numbers
Parameters
- $length : int
Return values
string —-- random string of length $length
nonsecureString()
This is the same as string, but uses a random generator that is not cryptographically secure
public
nonsecureString(string $characters, mixed $length) : mixed
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 : string
-
-- the alphabet of characters to use @param integer $length
@return string -- random string of length $length
- $length : mixed
Return values
mixed —string()
Generate a randon string from a given alphabet
public
string(string $characters, mixed $length) : mixed
Parameters
- $characters : string
-
-- the alphabet of characters to use @param integer $length
@return string -- random string of length $length
- $length : mixed
Return values
mixed —vbhash()
vBulletin's hash fetcher, note this may change from a-f0-9 to a-z0-9 in future.
public
vbhash([mixed $length = 32 ]) : string
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
- $length : mixed = 32