I'm having trouble understanding the difference between
A) return strcmp($digest, $signature) == 0;
and
B) return strcmp($digest, $signature);
Normally strcmp()
returns -1, 0, or 1 if the first string is less than, equal to, or greater than the second respectively. By comparing the result of that to 0 in
return strcmp($digest, $signature) == 0;
the result of strcmp()
is turned to a boolean that only tests for equality rather than greater than/less than by comparison. The function will return TRUE
if the two strings are equal (strcmp() == 0
), and FALSE
otherwise, discarding the other greater/less than information.