class RandomGenerator (View source)

Generates entropy values based on strongest available methods (mcrypt_create_iv(), openssl_random_pseudo_bytes(), /dev/urandom, COM.CAPICOM.Utilities.1, mt_rand()).

Chosen method depends on operating system and PHP version.

Methods

public
string
generateEntropy()

Note: Returned values are not guaranteed to be crypto-safe, depending on the used retrieval method.

public
string
randomToken(string $algorithm = 'whirlpool')

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

public
generateHash($algorithm = 'whirlpool') deprecated

No description

Details

string generateEntropy()

Note: Returned values are not guaranteed to be crypto-safe, depending on the used retrieval method.

Return Value

string

Returns a random series of bytes

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

generateHash($algorithm = 'whirlpool') deprecated

deprecated

No description

Parameters

$algorithm