mirror of
https://github.com/elyby/accounts.git
synced 2024-12-12 08:29:01 +05:30
20 lines
399 B
PHP
20 lines
399 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace common\components;
|
|
|
|
class UserFriendlyRandomKey {
|
|
|
|
public static function make(int $length = 18) {
|
|
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
|
$numChars = strlen($chars);
|
|
$key = '';
|
|
for ($i = 0; $i < $length; $i++) {
|
|
$key .= $chars[random_int(0, $numChars - 1)];
|
|
}
|
|
|
|
return $key;
|
|
}
|
|
|
|
}
|