Answer the question
In order to leave comments, you need to log in
How to write an algorithm to enumerate all possible combinations of characters?
We need an algorithm in PHP that will send a message to random emails, the email must be selected by brute force, 39 characters are allowed in the email (az, 1-9, dot, underscore, dash) - we are only interested in the part up to the dog. I can not understand in any way how the loop condition should be built. It is clear that the last character will change every 39 characters, the penultimate - every 39 squared, the penultimate - every 39 cubed, but I have no idea what to do with this knowledge.
Answer the question
In order to leave comments, you need to log in
well, something like that ... you give a number as input ...
function emailEncode($i)
{
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789._-";
$alphabet = str_split($alphabet);
if ($i == 0)
return $alphabet[0];
$result = '';
$base = count($alphabet);
while ($i > 0)
{
$result[] = $alphabet[($i % $base)];
$i = floor($i / $base);
}
$result = array_reverse($result);
return join("", $result);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question