I am trying to generate random alphanumeric string with numbers from 0-9 and letters from a - f and have the following code:-
<?php
function random_str($length, $keyspace = '0123456789abcdef')
{
$pieces = [];
$max = mb_strlen($keyspace, '8bit') - 1;
for ($i = 0; $i < $length; ++$i) {
$pieces []= $keyspace[random_int(0, $max)];
}
return implode('', $pieces);
}
$a = random_str(64);
echo $a;
?>
But the problem it generates a string with number of letters randomly but I want a string which has 64 characters in total and must have either 26 or 25 letters in total and rest should be numbers. They should not be seperated but mixed like this
7de5a1a5ae85e3aef5376333c3410ca984ef56f0c8082f9d6703414c01afbec3
Any help is appreciated.