GetRandom(64, 0)); return $e; } catch (Exception $ex) { } } // Fallback to good old mt_rand() return uniqid(mt_rand(), true); } /** * Generates a hash suitable for manual session identifiers, CSRF tokens, etc. * * @param String $algorithm Any identifier listed in hash_algos() (Default: whirlpool) * If possible, choose a slow algorithm which complicates brute force attacks. * @return String Returned length will depend on the used $algorithm */ function generateHash($algorithm = 'whirlpool') { return hash($algorithm, $this->generateEntropy()); } }