| @@ 318-331 (lines=14) @@ | ||
| 315 | * |
|
| 316 | * @return string |
|
| 317 | */ |
|
| 318 | public function token(int $length = 0): string { |
|
| 319 | $chars = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890'; |
|
| 320 | ||
| 321 | $str = ''; |
|
| 322 | $max = strlen($chars) - 1; |
|
| 323 | for ($i = 0; $i <= $length; $i++) { |
|
| 324 | try { |
|
| 325 | $str .= $chars[random_int(0, $max)]; |
|
| 326 | } catch (Exception $e) { |
|
| 327 | } |
|
| 328 | } |
|
| 329 | ||
| 330 | return $str; |
|
| 331 | } |
|
| 332 | ||
| 333 | } |
|
| 334 | ||
| @@ 949-962 (lines=14) @@ | ||
| 946 | * |
|
| 947 | * @return string |
|
| 948 | */ |
|
| 949 | protected function token(int $length = 15): string { |
|
| 950 | $chars = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890'; |
|
| 951 | ||
| 952 | $str = ''; |
|
| 953 | $max = strlen($chars); |
|
| 954 | for ($i = 0; $i < $length; $i++) { |
|
| 955 | try { |
|
| 956 | $str .= $chars[random_int(0, $max - 1)]; |
|
| 957 | } catch (Exception $e) { |
|
| 958 | } |
|
| 959 | } |
|
| 960 | ||
| 961 | return $str; |
|
| 962 | } |
|
| 963 | ||
| 964 | ||
| 965 | } |
|