]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - tests/utils/ReferenceSessionIdHashes.php
3 * Testing the untestable - Session ID generation
5 class ReferenceSessionIdHashes
8 protected static $sidHashes = null;
11 * Generates session ID hashes for all algorithms & bit representations
13 public static function genAllHashes()
15 foreach (hash_algos() as $algo) {
16 self
::$sidHashes[$algo] = array();
18 foreach (array(4, 5, 6) as $bpc) {
19 self
::$sidHashes[$algo][$bpc] = self
::genSidHash($algo, $bpc);
25 * Generates a session ID for a given hash algorithm and bit representation
27 * @param string $function name of the hash function
28 * @param int $bits_per_character representation type
30 * @return string the generated session ID
32 protected static function genSidHash($function, $bits_per_character)
38 ini_set('session.hash_function', $function);
39 ini_set('session.hash_bits_per_character', $bits_per_character);
46 * Returns the reference hash array
48 * @return array session IDs generated for all available algorithms and bit
51 public static function getHashes()
53 return self
::$sidHashes;