When I tested the crypt function, it returned different hashes than the ones listed in CS50's pset2, given the same salt and key:

char* testhash = crypt("rob", "50");
printf("hash for rob: %s\n", testhash);

testhash = crypt("brian", "50");
printf("hash for brian: %s\n", testhash);

return 0;

I got "50upJLRWneuTY" while CS50's hash for "rob" is "50JGnXUgaafgc", and "5044HIvTVFToI" while the hash for "brian" is "50mjprEcqC/ts". Why is this happening? Any inputs would be greatly appreciated :)


Maybe you are confusing two things. Those words on the left ("rob", "brian") are user names. The hashes are hashes of the associated passwords. That's a format you might find in the /etc/passwd file of a Linux system. I think there's a bit more on that in the problem's page, but if you're new you might still miss that bit.

You must log in to answer this question.

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