P
P
Pavel Kaptur2016-09-26 21:32:06
C++ / C#
Pavel Kaptur, 2016-09-26 21:32:06

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

1 answer(s)
T
T_y_l_e_r, 2016-09-26
@T_y_l_e_r

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;
    }

you twist the number from 0 to the desired one, at the output you get a string of characters, the
desired number is equal to the number of variations, in fact it is 62 to the 62nd power, but the number that will turn out is not real

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question