public static function random(int $length): string
    {
        $byteLength = ($length < 10) ? 10 : $length;
        $chars = base64_encode(random_bytes($byteLength));
        $chars = str_replace(["+", "/", "="], "", $chars);
        return substr($chars, 0, $length);
    }
public static function random(int $length): string
    {
        $byteLength = ($length < 10) ? 10 : $length;
        $chars = base64_encode(random_bytes($byteLength));
        $chars = str_replace(["+", "/", "="], "", $chars);
        return substr($chars, 0, $length);
    }
public static function random ( int $ length ) : string { $ byteLength = ( $ length < 10 ) ? 10 : $ length ; $ chars = base64_encode ( random_bytes ( $ byteLength ) ) ; $ chars = str_replace ( [ "+" , "/" , "=" ] , "" , $ chars ) ; return substr ( $ chars , 0 , $ length ) ; }
Get a random string

@param int $length The length of the resulting string
@return string
Get a random string