@@ -1,30 +1,30 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Random_* Compatibility Library |
|
4 | - * for using the new PHP 7 random_* API in PHP 5 projects |
|
5 | - * |
|
6 | - * The MIT License (MIT) |
|
7 | - * |
|
8 | - * Copyright (c) 2015 Paragon Initiative Enterprises |
|
9 | - * |
|
10 | - * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
11 | - * of this software and associated documentation files (the "Software"), to deal |
|
12 | - * in the Software without restriction, including without limitation the rights |
|
13 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
14 | - * copies of the Software, and to permit persons to whom the Software is |
|
15 | - * furnished to do so, subject to the following conditions: |
|
16 | - * |
|
17 | - * The above copyright notice and this permission notice shall be included in |
|
18 | - * all copies or substantial portions of the Software. |
|
19 | - * |
|
20 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
21 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
22 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
23 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
24 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
25 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
26 | - * SOFTWARE. |
|
27 | - */ |
|
3 | + * Random_* Compatibility Library |
|
4 | + * for using the new PHP 7 random_* API in PHP 5 projects |
|
5 | + * |
|
6 | + * The MIT License (MIT) |
|
7 | + * |
|
8 | + * Copyright (c) 2015 Paragon Initiative Enterprises |
|
9 | + * |
|
10 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
11 | + * of this software and associated documentation files (the "Software"), to deal |
|
12 | + * in the Software without restriction, including without limitation the rights |
|
13 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
14 | + * copies of the Software, and to permit persons to whom the Software is |
|
15 | + * furnished to do so, subject to the following conditions: |
|
16 | + * |
|
17 | + * The above copyright notice and this permission notice shall be included in |
|
18 | + * all copies or substantial portions of the Software. |
|
19 | + * |
|
20 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
21 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
22 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
23 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
24 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
25 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
26 | + * SOFTWARE. |
|
27 | + */ |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Since openssl_random_pseudo_bytes() uses openssl's |
@@ -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 | { |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | |
47 | 47 | $RandomCompatDIR = dirname(__FILE__); |
48 | 48 | |
49 | - require_once $RandomCompatDIR.'/byte_safe_strings.php'; |
|
50 | - require_once $RandomCompatDIR.'/cast_to_int.php'; |
|
51 | - require_once $RandomCompatDIR.'/error_polyfill.php'; |
|
49 | + require_once $RandomCompatDIR . '/byte_safe_strings.php'; |
|
50 | + require_once $RandomCompatDIR . '/cast_to_int.php'; |
|
51 | + require_once $RandomCompatDIR . '/error_polyfill.php'; |
|
52 | 52 | |
53 | 53 | if (!function_exists('random_bytes')) { |
54 | 54 | /** |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | if (extension_loaded('libsodium')) { |
70 | 70 | // See random_bytes_libsodium.php |
71 | 71 | if (PHP_VERSION_ID >= 50300 && function_exists('\\Sodium\\randombytes_buf')) { |
72 | - require_once $RandomCompatDIR.'/random_bytes_libsodium.php'; |
|
72 | + require_once $RandomCompatDIR . '/random_bytes_libsodium.php'; |
|
73 | 73 | } elseif (method_exists('Sodium', 'randombytes_buf')) { |
74 | - require_once $RandomCompatDIR.'/random_bytes_libsodium_legacy.php'; |
|
74 | + require_once $RandomCompatDIR . '/random_bytes_libsodium_legacy.php'; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | // place, that is not helpful to us here. |
111 | 111 | |
112 | 112 | // See random_bytes_dev_urandom.php |
113 | - require_once $RandomCompatDIR.'/random_bytes_dev_urandom.php'; |
|
113 | + require_once $RandomCompatDIR . '/random_bytes_dev_urandom.php'; |
|
114 | 114 | } |
115 | 115 | // Unset variables after use |
116 | 116 | $RandomCompat_basedir = null; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613) |
135 | 135 | ) { |
136 | 136 | // See random_bytes_mcrypt.php |
137 | - require_once $RandomCompatDIR.'/random_bytes_mcrypt.php'; |
|
137 | + require_once $RandomCompatDIR . '/random_bytes_mcrypt.php'; |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); |
156 | 156 | if (method_exists($RandomCompatCOMtest, 'GetRandom')) { |
157 | 157 | // See random_bytes_com_dotnet.php |
158 | - require_once $RandomCompatDIR.'/random_bytes_com_dotnet.php'; |
|
158 | + require_once $RandomCompatDIR . '/random_bytes_com_dotnet.php'; |
|
159 | 159 | } |
160 | 160 | } catch (com_exception $e) { |
161 | 161 | // Don't try to use it. |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | extension_loaded('openssl') |
187 | 187 | ) { |
188 | 188 | // See random_bytes_openssl.php |
189 | - require_once $RandomCompatDIR.'/random_bytes_openssl.php'; |
|
189 | + require_once $RandomCompatDIR . '/random_bytes_openssl.php'; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | if (!function_exists('random_int')) { |
210 | - require_once $RandomCompatDIR.'/random_int.php'; |
|
210 | + require_once $RandomCompatDIR . '/random_int.php'; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | $RandomCompatDIR = null; |
@@ -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 |