| @@ 986-999 (lines=14) @@ | ||
| 983 | * |
|
| 984 | * @return string |
|
| 985 | */ |
|
| 986 | protected function token(int $length = 15): string { |
|
| 987 | $chars = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890'; |
|
| 988 | ||
| 989 | $str = ''; |
|
| 990 | $max = strlen($chars); |
|
| 991 | for ($i = 0; $i < $length; $i++) { |
|
| 992 | try { |
|
| 993 | $str .= $chars[random_int(0, $max - 1)]; |
|
| 994 | } catch (Exception $e) { |
|
| 995 | } |
|
| 996 | } |
|
| 997 | ||
| 998 | return $str; |
|
| 999 | } |
|
| 1000 | ||
| 1001 | ||
| 1002 | } |
|
| @@ 340-353 (lines=14) @@ | ||
| 337 | * |
|
| 338 | * @return string |
|
| 339 | */ |
|
| 340 | public function token(int $length = 0): string { |
|
| 341 | $chars = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890'; |
|
| 342 | ||
| 343 | $str = ''; |
|
| 344 | $max = strlen($chars) - 1; |
|
| 345 | for ($i = 0; $i <= $length; $i++) { |
|
| 346 | try { |
|
| 347 | $str .= $chars[random_int(0, $max)]; |
|
| 348 | } catch (Exception $e) { |
|
| 349 | } |
|
| 350 | } |
|
| 351 | ||
| 352 | return $str; |
|
| 353 | } |
|
| 354 | ||
| 355 | } |
|
| 356 | ||