17 lines
316 B
PHP
17 lines
316 B
PHP
|
<?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
|
||
|
);
|
||
|
}
|
||
|
}
|