Probably a silly question, but please bear with me as I'm pretty new to this.
I'm stuck with Crack in Pset2. Can't wrap my head around how to go about iterating through all combinations of alphabet.
All big and small alphabetical characters are loaded to array alpha
(to leave out all non-alphabetical ones) and I want to be loading their combinations to array pass
that is then encrypted, and the hash is then compared with the given hash coded
. It works for one letter passwords with the below code, and I just can't figure out how to take it to 4 character pass
. Would appreciate any direction or hint. I tried with nested for
functions but that didn't work for pass
shorter than 4 characters.
int check, a;
for ( a = 0; a < 56; a++)
{
pass[0] = alpha[a];
pass[1] = '\0';
check = strcmp(coded, crypt(pass,salt));
if ( check == 0 )
{
printf("%s\n", pass);
return 0;
}
}