I am doing PSET2 "Hacker Edition". I did used dictonary and It worked fine for cracking some passwords.I want to generate all the possible characters in incrementing order but I am unable to think the right algorithm. My code is:
char word[9]; word[8] = '\n';
for(int a =64; a < 123; a++)
{
word[0] = a;
for(int b =64; b < 123; b++)
{
word[1] = b;
for(int c =64; c < 123; c++)
{
word[2] = c;
for(int d =64; d < 123; d++)
{
word[3] = d;
for(int e =64; e < 123; e++)
{
word[4] = e;
for(int f =64; f < 123; f++)
{
word[5] = f;
for(int g =64; g < 123; g++)
{
word[6] = g;
for(int h =64; h < 123; h++)
{
word[7] = h;
//do something with the word.
}
}
}
}
}
}
}
}
The problem is my code only works for fixed sized password(as many as the no of loops) in this case 8. Also it seems that I am repeating same code many times thus making the code ugly and dirty. Please help me, maybe with some pseudocode.