I have completed all problems in psets 0, 1, 2 comfortably except for the last problem. Crack.c (more comfortable version). I read the cs50 crack.c page and I also watched the walk through twice but still I am not able to understand a lot of things they are mentioning. What is password hashing in the first place? I only understand that crack.c is a program that should crack DES encrypted passwords and that there is some function called 'crypt()'. I don't know what it does but I could not understand anything else. What exactly is the 'Problem'?
Just imagine one day you get a "hashed password" that could be used to log into your girlfriend's email, what will you do? Is it possible to log into the email with that "hashed password"? Of course, NO, because the "hashed" (or "encrypted") password contains non-sense characters. Typing that encrypted string into the log-in window will lead to the error message of "wrong username/ password".
Now imagine further what if you know the encryption method (crypt function), and the password is alphabet ONLY, with not more than 4 characters? You might consider to do the "guessing" game, following this way: - try a random password, encrypt it (using crypt function), if the result is the same as the "hashed" one mentioned above, then "eureka", you find it. If not, try another password. - repeat the trying process until you find a matching.
However, we should not rely on "randomization" but a scientific sequence to solve the problem: - we try with all passwords of 1 character first, if the true password is there, it's there. Otherwise, next. - we then try with all password of 2 characters, - then try with 3 characters - finally with 4 characters
You will soon or later find a matched password (through comparing the hashed ones) among those tryings.
The problem is a little more complicated, but in general that's the main idea.
Let me know if you still have any question.