-1

my auth not working like, my code is below.

<?php
$login = "super";
printf(crc32($login)); // result -691938802
printf("%u",crc32($login)); //result 3603028494
if(crc32($login) * -1 == -3603028494) {
    echo "user correct";
}else{
    echo "user false";
}
?>

i always getting user false, so, i think the problem come from %u , how i can change my $login variable with something like $login = "%usuper" so my auth code working ? is it possible change $login value only without change if condition, because i will use it in login form in the future.

Thanks.

Dark Cyber
  • 2,181
  • 7
  • 44
  • 68
  • I'm not sure why you expect -691938802 * -1 to be a negative number in PHP. Or were you expecting `printf("%u", ...` to convert the result of `crc32($login)` to an unsigned integer every time you call that function in the future? – Cairnarvon Feb 16 '15 at 03:32
  • @Cairnarvon, exactly i learn to answer quiz , and the simple code looks like my code , so in this case how i can pass to user correct with the above condition given from the quiz. – Dark Cyber Feb 16 '15 at 05:11

1 Answers1

0

crc32() returns an int, which is a signed 32-bit integer. The two numbers you are showing are the same number, i.e. exactly the same 32 bits, just interpreted differently. 2^32 - 691938802 == 3603028494. There is no problem.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
  • if both number is same , then why i always getting user false ? the if condition is as is since i learn answer quiz. so how i can modify "super" string ? Thanks. – Dark Cyber Feb 16 '15 at 08:01
  • I can't figure out what you're asking. In the code you show, it makes no sense to multiply by -1. Just compare to -691938802. It is not clear how what you have written is used in the context of a real program. Obviously you can determine that `crc32("super")==crc32("super")`. – Mark Adler Feb 16 '15 at 08:12