everyone! I could use some help on crack.c problem. I tried to create a program that creates 1 to 4 random uppercase and lowercase chars, crypts them and compares them to hash. It works but it may take about a month to find the password, lol. I tried a different approach using words dictionary in cs50 ide. It also works for words that are on dictionary. But what about the random chars? Also random uppercase and lowercase chars? I am completely stuck. Anyone has a hint on that? Thanks in advance.
1 Answer
You shouldn't create random combinations of letters, you should go through every possible combination of letters and try each combination only once like this (assuming only lowercase letters but in the actual crack program you need to do this for both uppercase and lowercase):
a, b, c, d, e ... z aa, ab, ac, ad ... az ba, bb, bc, bd ... bz
aaa, aab ... aba, abb, , abc ... azz ... zzz
So in short, you need to go from "a" to "zzzz", sort of in the same way you would count from 1 to 9999 but with the letters of the alphabet instead of numbers.
\0\0\0a
toZZZZ
in almost 6 minutes...