Answer the question
In order to leave comments, you need to log in
How to generate string for brute force?
Greetings to all, a question arose related to brute force, I want to select a key from 16 characters and with the alphabet 1-9 AZ, respectively, it is necessary to generate keys. And here I can’t figure out how to do it, how conveniently and as quickly as possible to generate keys. Only 16 nested loops come to mind, but that's creepy. But I can't figure out how to do it wrong. There is another option with recursion, but I don’t really like it either. In which direction to dig?
Answer the question
In order to leave comments, you need to log in
Like this, about
public function toBase($num, $b=62) {
$base='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$r = $num % $b ;
$res = $base[$r];
$q = floor($num/$b);
while ($q) {
$r = $q % $b;
$q =floor($q/$b);
$res = $base[$r].$res;
}
return $res;
}
public function to10( $num, $b=62) {
$base='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$limit = strlen($num);
$res=strpos($base,$num[0]);
for($i=1;$i<$limit;$i++) {
$res = $b * $res + strpos($base,$num[$i]);
}
return $res;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question