php – crc32 function


(PHP 4 >= 4.0.1, PHP 5)
crc32 — Calculates the crc32 polynomial of a string
int crc32 ( string str )

Generates the cyclic redundancy checksum polynomial of 32-bit lengths of the str. This is usually used to validate the integrity of data being transmitted.

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.

This second example shows how to print a converted checksum with the printf() function:

Example 1. Displaying a crc32 checksum
$checksum = crc32(“The quick brown fox jumped over the lazy dog.”);
printf(“%u\n”, $checksum);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: