-1

edited posted due to solved problem

2

This is because when you reach the innermost loop for the first time, your array is already four characters. Now for all the permutations you will have four characters in the array. This is the reason it works only with four character hashed passwords. Only if the password was 'a' or 'aa' or 'aaa' would it work. I tried to make it work using four different arrays for four diff length of characters. I used four diff loops to permute over those four arrays.

3
  • can your send your edited code ?? – Vikrant Pradhan Apr 30 '17 at 16:51
  • Let me suggest you a few things: First, you have hardwired the string "50" to the salt parameter. Instead it should be the first two characters of whatever the hashed password is. Second, initialize the arrays as pguess1[3] = { NULL}; . This sets the values of empty array to NULL. In doing so you avoid the use of garbage values. Lastly, after the if statement for comparing the password and printing out the password use a return value (most likely return 0) to stop the program else the program will run till the end even after finding the password which makes it a bad design. – Vikrant Pradhan May 1 '17 at 4:43
  • try pguess1[3] = {0} or if you get error then just give it a initial string value like pguess1[3] = "aa" (the last element will implicitly be NULL) and pguess[4] = "aaa". – Vikrant Pradhan May 2 '17 at 5:07

You must log in to answer this question.

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