2016-01-15 14:51:27 +05:30
|
|
|
<?php
|
2018-04-18 02:17:25 +05:30
|
|
|
declare(strict_types=1);
|
2016-01-15 14:51:27 +05:30
|
|
|
|
2018-04-18 02:17:25 +05:30
|
|
|
namespace common\components;
|
2016-01-15 14:51:27 +05:30
|
|
|
|
|
|
|
class UserFriendlyRandomKey {
|
|
|
|
|
2018-04-18 02:17:25 +05:30
|
|
|
public static function make(int $length = 18) {
|
2016-01-15 14:51:27 +05:30
|
|
|
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
|
|
|
$numChars = strlen($chars);
|
|
|
|
$key = '';
|
|
|
|
for ($i = 0; $i < $length; $i++) {
|
2016-11-01 22:06:39 +05:30
|
|
|
$key .= $chars[random_int(0, $numChars - 1)];
|
2016-01-15 14:51:27 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return $key;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|