so, for pset2 crack task i've generate a password, then encrypt this password and a salt to some result by
result = crypt(pass, salt);
After i want to compare result with hash, so i implemented a bool function, that compares them, and if it is equal - print password and return 'true', otherwise - return 'false'
bool cmp(string res, string h, string p)
{
if (strcmp(res, h)==0)
{
printf("%s\n", p);
return true;
}
return false;
}
and then use it as:
if (cmp(result, hash, pass))
return 0;
to end program in case if result(crypted password by salt) equals to hash, as requested in task.
Question is - is it possible to exit by return 0; right from bool function in case if 'true', so then use of the function can looks like just
cmp(result, hash, pass);
perhaps?Can such solution be done?
Thanks.