1 | <?php |
||
11 | class RandomGenerator |
||
12 | { |
||
13 | /** |
||
14 | * @return string A 128-character, randomly generated ASCII string |
||
15 | * @throws Exception If no suitable CSPRNG is installed |
||
16 | */ |
||
17 | public function generateEntropy() |
||
31 | |||
32 | /** |
||
33 | * Generates a random token that can be used for session IDs, CSRF tokens etc., based on |
||
34 | * hash algorithms. |
||
35 | * |
||
36 | * If you are using it as a password equivalent (e.g. autologin token) do NOT store it |
||
37 | * in the database as a plain text but encrypt it with Member::encryptWithUserSettings. |
||
38 | * |
||
39 | * @param string $algorithm Any identifier listed in hash_algos() (Default: whirlpool) |
||
40 | * @return string Returned length will depend on the used $algorithm |
||
41 | */ |
||
42 | public function randomToken($algorithm = 'whirlpool') |
||
46 | } |
||
47 |