GetRandom(64, 0)); } } catch (Exception $ex) { } } // Fallback to good old mt_rand() return uniqid(mt_rand(), true); } /** * 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. * * @param String $algorithm Any identifier listed in hash_algos() (Default: whirlpool) * * @return String Returned length will depend on the used $algorithm */ public function randomToken($algorithm = 'whirlpool') { return hash($algorithm, $this->generateEntropy()); } }