Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
44 | public static function auth($len) |
||
45 | { |
||
46 | // All code bellow does the same - generate as safe as possible random string |
||
47 | // no need for full coverage test ;) |
||
48 | // @codeCoverageIgnoreStart |
||
49 | if (function_exists('random_bytes')) { |
||
50 | $randomBytes = random_bytes($len); |
||
51 | } elseif (function_exists('openssl_random_pseudo_bytes')) { |
||
52 | $randomBytes = openssl_random_pseudo_bytes($len); |
||
53 | } else { |
||
54 | $randomBytes = mcrypt_create_iv($len, MCRYPT_DEV_URANDOM); |
||
55 | } |
||
56 | // @codeCoverageIgnoreEnd |
||
57 | |||
58 | $randomBytes = base64_encode($randomBytes); |
||
59 | |||
60 | return substr(rtrim($randomBytes, '='), 0, $len); |
||
61 | } |
||
62 | } |
||
63 |