- substr: documentation ( source)
- bin2hex: documentation ( source)
- base_convert: documentation ( source)
<?php
function random($length = 8)
{
return substr(base_convert(bin2hex(openssl_random_pseudo_bytes($length)), 16, 36), 0, $length);
}
/*
function random($length = 8)
{
return strtr(substr(base64_encode(openssl_random_pseudo_bytes($length)), 0, $length), '/+=', '_-.');
}
*/
for ($i=1; $i<64; $i++)
{
$str = random($i);
echo "$str\n";
}