@@ -165,6 +165,7 @@ |
||
165 | 165 | /** |
166 | 166 | * We don't have any more options, so let's throw an exception right now |
167 | 167 | * and hope the developer won't let it fail silently. |
168 | + * @param integer $length |
|
168 | 169 | */ |
169 | 170 | function random_bytes($length) |
170 | 171 | { |
@@ -1,33 +1,33 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Random_* Compatibility Library |
|
4 | - * for using the new PHP 7 random_* API in PHP 5 projects |
|
5 | - * |
|
6 | - * @version 1.2.2 |
|
7 | - * @released 2016-03-11 |
|
8 | - * |
|
9 | - * The MIT License (MIT) |
|
10 | - * |
|
11 | - * Copyright (c) 2015 Paragon Initiative Enterprises |
|
12 | - * |
|
13 | - * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
14 | - * of this software and associated documentation files (the "Software"), to deal |
|
15 | - * in the Software without restriction, including without limitation the rights |
|
16 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
17 | - * copies of the Software, and to permit persons to whom the Software is |
|
18 | - * furnished to do so, subject to the following conditions: |
|
19 | - * |
|
20 | - * The above copyright notice and this permission notice shall be included in |
|
21 | - * all copies or substantial portions of the Software. |
|
22 | - * |
|
23 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
24 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
25 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
26 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
27 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
28 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
29 | - * SOFTWARE. |
|
30 | - */ |
|
3 | + * Random_* Compatibility Library |
|
4 | + * for using the new PHP 7 random_* API in PHP 5 projects |
|
5 | + * |
|
6 | + * @version 1.2.2 |
|
7 | + * @released 2016-03-11 |
|
8 | + * |
|
9 | + * The MIT License (MIT) |
|
10 | + * |
|
11 | + * Copyright (c) 2015 Paragon Initiative Enterprises |
|
12 | + * |
|
13 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
14 | + * of this software and associated documentation files (the "Software"), to deal |
|
15 | + * in the Software without restriction, including without limitation the rights |
|
16 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
17 | + * copies of the Software, and to permit persons to whom the Software is |
|
18 | + * furnished to do so, subject to the following conditions: |
|
19 | + * |
|
20 | + * The above copyright notice and this permission notice shall be included in |
|
21 | + * all copies or substantial portions of the Software. |
|
22 | + * |
|
23 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
24 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
25 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
26 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
27 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
28 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
29 | + * SOFTWARE. |
|
30 | + */ |
|
31 | 31 | |
32 | 32 | if (!defined('PHP_VERSION_ID')) { |
33 | 33 | // This constant was introduced in PHP 5.2.7 |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | $RandomCompatDIR = dirname(__FILE__); |
51 | 51 | |
52 | - require_once $RandomCompatDIR.'/byte_safe_strings.php'; |
|
53 | - require_once $RandomCompatDIR.'/cast_to_int.php'; |
|
54 | - require_once $RandomCompatDIR.'/error_polyfill.php'; |
|
52 | + require_once $RandomCompatDIR . '/byte_safe_strings.php'; |
|
53 | + require_once $RandomCompatDIR . '/cast_to_int.php'; |
|
54 | + require_once $RandomCompatDIR . '/error_polyfill.php'; |
|
55 | 55 | |
56 | 56 | if (!function_exists('random_bytes')) { |
57 | 57 | /** |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | if (extension_loaded('libsodium')) { |
73 | 73 | // See random_bytes_libsodium.php |
74 | 74 | if (PHP_VERSION_ID >= 50300 && function_exists('\\Sodium\\randombytes_buf')) { |
75 | - require_once $RandomCompatDIR.'/random_bytes_libsodium.php'; |
|
75 | + require_once $RandomCompatDIR . '/random_bytes_libsodium.php'; |
|
76 | 76 | } elseif (method_exists('Sodium', 'randombytes_buf')) { |
77 | - require_once $RandomCompatDIR.'/random_bytes_libsodium_legacy.php'; |
|
77 | + require_once $RandomCompatDIR . '/random_bytes_libsodium_legacy.php'; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | // place, that is not helpful to us here. |
114 | 114 | |
115 | 115 | // See random_bytes_dev_urandom.php |
116 | - require_once $RandomCompatDIR.'/random_bytes_dev_urandom.php'; |
|
116 | + require_once $RandomCompatDIR . '/random_bytes_dev_urandom.php'; |
|
117 | 117 | } |
118 | 118 | // Unset variables after use |
119 | 119 | $RandomCompat_basedir = null; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613) |
141 | 141 | ) { |
142 | 142 | // See random_bytes_mcrypt.php |
143 | - require_once $RandomCompatDIR.'/random_bytes_mcrypt.php'; |
|
143 | + require_once $RandomCompatDIR . '/random_bytes_mcrypt.php'; |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | $RandomCompatUrandom = null; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); |
163 | 163 | if (method_exists($RandomCompatCOMtest, 'GetRandom')) { |
164 | 164 | // See random_bytes_com_dotnet.php |
165 | - require_once $RandomCompatDIR.'/random_bytes_com_dotnet.php'; |
|
165 | + require_once $RandomCompatDIR . '/random_bytes_com_dotnet.php'; |
|
166 | 166 | } |
167 | 167 | } catch (com_exception $e) { |
168 | 168 | // Don't try to use it. |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | if (!function_exists('random_int')) { |
193 | - require_once $RandomCompatDIR.'/random_int.php'; |
|
193 | + require_once $RandomCompatDIR . '/random_int.php'; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | $RandomCompatDIR = null; |