I'm working through Pset2: Crack but I don't think the background matters here.
I'm having some problems with the output of the crypt()
function and I have been trying to figure what the problem is - I think it's because crypt()
outputs a pointer? I'm only 2 weeks into cs50 and I've had a read around pointers. I understand that it doesn't actually store the data I am looking for but an address line to the data within the memory but that knowledge doesn't explain, to me, why I can't use the output of crypt()
with an equaliser ==
.
Anyway, any help with the code below or further reading is appreciated.
int main(int argc, string argv[])
{
string key = "f";
string salt = "50";
string a = crypt(key, salt);
string x = "50AWs/7oe6pkA"; // this is the hash output from crypt(f, 50)
if(a == x)
{
printf("true\n");
}
}
I expect output of "true" but (a == x) is not passing the if condition