2022-12-30 19:03:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class PassGen
|
|
|
|
{
|
|
|
|
public static function new($length = 8)
|
|
|
|
{
|
|
|
|
return substr(
|
|
|
|
preg_replace(
|
|
|
|
"/[^a-zA-Z0-9]/",
|
|
|
|
"",
|
|
|
|
base64_encode(openssl_random_pseudo_bytes($length + 1))
|
|
|
|
),
|
|
|
|
0,
|
|
|
|
$length
|
|
|
|
);
|
|
|
|
}
|
2023-01-06 14:57:25 +00:00
|
|
|
|
|
|
|
public static function intCode($length = 8): int
|
|
|
|
{
|
|
|
|
return mt_rand(10 ** ($length - 1), 10 ** $length - 1);
|
|
|
|
}
|
2022-12-30 19:03:37 +00:00
|
|
|
}
|