15 lines
427 B
PHP
15 lines
427 B
PHP
<?php
|
|
namespace Mince;
|
|
|
|
final class Utils {
|
|
private const CHARS = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789';
|
|
|
|
public static function generatePassKey(int $length): string {
|
|
$keyChars = strlen(self::CHARS) - 1;
|
|
$bytes = str_repeat("\0", $length);
|
|
for($i = 0; $i < $length; ++$i)
|
|
$bytes[$i] = self::CHARS[random_int(0, $keyChars)];
|
|
return $bytes;
|
|
}
|
|
}
|