1

Any advice on why the code isn't running? Yet it compiles?

Code Link: https://pastebin.com/XMhgJ49k

Thanks!

1
  • Almost what happened to me. Except that it printed Killed Mar 26 '19 at 2:41
1
  1. Password could be 5 characters long and not 4 characters.
  2. You cannot compare strings by == operator. Instead use strcmp() from string.h header file.
  3. Take hashed password from command line itself. Then argc = 2 & argv[1] will have the hashed password.
  4. Instead of checking password for 1 letter, 2 letters, and so on, in different looping structures, why don't you try to use the iterations once and check it there itself. Suppose if the password is 10 characters long, what will you do then?
3
  • I don't really understand point number 4, but I have amended points 1-3 as per your advice. Can you elaborate please? Please find the advised code: pastebin.com/r2BdziUf And yes, unfortunately this code is limited to passwords 4 characters long, I can't figure out how to set it to an arbitrary length of characters. Sep 13 '18 at 12:23
  • @YeungBenjamin What he basically means (according to what I understood) is that instead of checking passwords by how many characters they have, use nested loops (I guess? 😬) Mar 26 '19 at 3:51
  • Point 4 - instead of using separate blocks of loops to test 1 character password, then 2 character password, then 3, 4 and so on, why not use them in one block of code itself with nested loops. It will be more clear by doing this, move the code between line 37 and 44 (including lines 37 and 44) to a new line after line 49 and before 50. Convince yourself that the logic will work (maybe a break statement is required.). You have now removed one redundant loop block. do same for other blocks. Blocks in his code starts with - // testing for password with n characters length Mar 26 '19 at 10:37
0

I advice you to see this link, and to use functions (like string crack(string hashed) or someting like that, instead of dumping everything in main().

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .