<?php
function random_password(int $min, int $max)
{
$allowed = array_merge(
[33, 60, 62, 94, 95],
range(48, 57),
range(64, 90),
range(97, 122)
);
$l = random_int($min, $max);
$chars = [];
while ($l--) {
$bi = random_int(0, count($allowed)-1);
$chars[] = chr($allowed[$bi]);
}
return implode('', $chars);
}
var_dump(random_password(8, 12));
preferences:
31.22 ms | 402 KiB | 5 Q