class RandomGenerator

Convenience class for generating cryptographically secure pseudo-random strings/tokens

Methods

string
generateEntropy() deprecated

No description

string
randomToken(string $algorithm = 'whirlpool')

Generates a random token that can be used for session IDs, CSRF tokens etc., based on hash algorithms.

Details

at line 19
string generateEntropy() deprecated

deprecated 4.4.0:5.0.0

Return Value

string A 128-character, randomly generated ASCII string

Exceptions

Exception If no suitable CSPRNG is installed

at line 47
string randomToken(string $algorithm = 'whirlpool')

Generates a random token that can be used for session IDs, CSRF tokens etc., based on hash algorithms.

If you are using it as a password equivalent (e.g. autologin token) do NOT store it in the database as a plain text but encrypt it with Member::encryptWithUserSettings.

Parameters

string $algorithm Any identifier listed in hash_algos() (Default: whirlpool)

Return Value

string Returned length will depend on the used $algorithm

Exceptions

Exception When there is no valid source of CSPRNG