i can get crypt to print the expected hash when i put the string directly into the function. however when passing a char array in i seem to be getting a different hash. Any suggestions?

 char password3[3];
 password3[0] = alphabet[i];
 password3[1] = alphabet[j];
 password3[2] = alphabet[k];

 printf("%s\n", password3);
 //Use crypt to hash new password using salt from user inputed hash
 //Compare user hash with hashed guessed password
 printf("%s\n", (crypt(password3, salt)));
 printf("%s\n", userhash);
 if (strcmp(userhash, crypt(password3, salt)) == 0)

Result LOL 50z.apvJv.NgQ

which is not correct.


What's in alphabet?

password3[2] = alphabet[k];

The salt is the first two digits of the hash, not the first 3. password3[2] needs to be set to the end of string marker, '\0'.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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