Query: crc32
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
CRC32(3) 1 CRC32(3) crc32 - Calculates the crc32 polynomial of a stringSYNOPSISint crc32 (string $str)DESCRIPTIONGenerates the cyclic redundancy checksum polynomial of 32-bit lengths of the $str. This is usually used to validate the integrity of data being transmitted. Warning Because PHP's integer type is signed many crc32 checksums will result in negative integers on 32bit platforms. On 64bit installa- tions all crc32(3) results will be positive integers though. So you need to use the "%u" formatter of sprintf(3) or printf(3) to get the string representation of the unsigned crc32(3) checksum in decimal format. For a hexadecimal representation of the checksum you can either use the "%x" formatter of sprintf(3) or printf(3) or the dechex(3) conversion functions, both of these also take care of converting the crc32(3) result to an unsigned integer. Having 64bit installations also return negative integers for higher result values was considered but would break the hexadecimal conversion as negatives would get an extra 0xFFFFFFFF######## offset then. As hexadecimal representation seems to be the most common use case we decided to not break this even if it breaks direct decimal comparisons in about 50% of the cases when moving from 32 to 64bits. In retrospect having the function return an integer maybe wasn't the best idea and returning a hex string representation right away (as e.g. md5(3) does) might have been a better plan to begin with. For a more portable solution you may also consider the generic hash(3). hash("crc32b", $str) will return the same string as dechex(crc32($str)).PARAMETERSo $str - The data.RETURN VALUESReturns the crc32 checksum of $str as an integer.EXAMPLESExample #1 Displaying a crc32 checksum This example shows how to print a converted checksum with the printf(3) function: <?php $checksum = crc32("The quick brown fox jumped over the lazy dog."); printf("%u ", $checksum); ?>SEE ALSOhash(3), md5(3), sha1(3). PHP Documentation Group CRC32(3)
Related Man Pages |
---|
crc16(n) - osx |
crc32(3tcl) - debian |
crc32(n) - suse |
sum(n) - suse |
crc32(n) - osx |
Similar Topics in the Unix Linux Community |
---|
32bit to 64bit conversion. |
Checking for the presence of a string within another string |
How do i install swftools with rhel5.3 64bit |
Using cvsup on a 64bit-OpenBSD |
cksum does not give me crc32 |