So I found an old backup and have a encrypted file. I know some of the letters in the password so I tried searching for a bruteforce program but I kinda gave up on that lol. I figured it wouldnt take much to figure this out myself.
Then I ran into this problem. If I have the possible characters into an array, I figured if I just put it into a loop and go through each character and inside that go through each charcter, etc I would get all the possibilities.
Basically if I have this it echos out:Code:<pre>
<?PHP
$eol = "\n";
$chars = array("a", "b", "c");
$i = 0;
while($i < count($chars)) {
$ii = 0;
while($ii < count($chars)) {
$iii = 0;
while($iii < count($chars)) {
echo $chars[$i].$chars[$ii].$chars[$iii].$eol;
$iii++;
}
$ii++;
}
$i++;
}
?>
</pre>
Which is correct but what if I want more than 3 caracters? Is there an easier way to do this then to embed more loops inside the loops? In that case if I wasnt sure if it was say 6 characters or 7 characters id have to run the program with 6 loops, then that fails I go again with 7? Is there a way to do this and just run it once? There has gotta be another way then 17+ embed loops lolaaa
aab
aac
aba
abb
abc
aca
acb
acc
baa
bab
bac
bba
bbb
bbc
bca
bcb
bcc
caa
cab
cac
cba
cbb
cbc
cca
ccb
ccc


LinkBack URL
About LinkBacks







Reply With Quote








Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum