ok doczytalem na php.net.
Because PHP's integer type is signed, and many crc32 checksums will result in negative integers, you need to use the "%u" formatter of sprintf() or printf() to get the string representation of the unsigned crc32 checksum.
W zasadzie dopiero startuje z Perlem i mam problem w przekształceniu rezultatu string::crc32 na odpowiednik PHP crc32.
#!/usr/bin/perl -w
use strict;
use warnings;
use integer;
use String::CRC32;
use POSIX;
my $php = -821904548; #php crc32('abc')
my $perl = 3473062748; #perl string::crc32('abc')
print "INT_MAX : " . INT_MAX . "\n";
printf("Perl HEX: %#X \n", $perl );
printf("Perl Signed Decimal: %d\n", $perl);
printf("PHP HEX: %#X \n", $php );
use integer miało załatwić sprawe z printf z konwersją '%u':
%d - a signed integer, in decimal
natomiast zwraca mi tą samą wartość z zmiennej $perl.
ouput:
[dawid@nestle ~]$ ./test.pl
INT_MAX : 2147483647
Perl HEX: 0XCF02BB5C
Perl Signed Decimal: 3473062748
PHP HEX: 0XFFFFFFFFCF02BB5C
Proszę o podpowiedź.
pozdrawiam
dawid