CRC32(1) General Commands Manual CRC32(1)NAME
crc32 - compute CRC-32 checksums for the given files
SYNOPSIS
crc32 filename [ filename ... ]
DESCRIPTION
crc32 is a simple utility that calculates the CRC-32 checksum for each of the given files.
Note that the CRC-32 checksum is merely used for error detection in transmission and storage. It is not intended to guard against the
malicious modification of files (i.e., it is not a cryptographic hash).
This utility is supplied with the Archive::Zip module for Perl.
SEE ALSO Archive::Zip(3pm).
AUTHOR
The Archive::Zip module was written by Ned Konz.
This manual page was prepared by Ben Burton <bab@debian.org> for the Debian GNU/Linux system (but may be used by others).
June 21, 2005 CRC32(1)
Check Out this Related Man Page
CRC32(3) 1 CRC32(3)crc32 - Calculates the crc32 polynomial of a stringSYNOPSIS
int crc32 (string $str)
DESCRIPTION
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.
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)).
PARAMETERS
o $str
- The data.
RETURN VALUES
Returns the crc32 checksum of $str as an integer.
EXAMPLES
Example #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 ALSO hash(3), md5(3), sha1(3).
PHP Documentation Group CRC32(3)
Hello!
For long I used cksum to find file duplicates in linux and darwin.
Now I want to make my own program that does all.
However I can't seem to find the correct algorithm.
zip and cksum claim to use the same algorithm, but the computated sums are not the same.
I've already written an... (4 Replies)
Is cksum the right command to calculate the crc32 checksum value? I tried it for a number of files now and every time the results dont match. So there is nothing wrong with the file. Also, cksum gives me an all numerical value while crc32 is alpha numeric. What am I doing wrong?
Thanks (9 Replies)
I would like to list all files in a directory tree but with a prepended digest hash code (like CRC32). CRC32 is not a MUST. If suitable another hash code can be used as well. In case of CRC32 the listing should look like
3765AC \usr\bin\spool
23CE99 \usr\bin\spool\list.h
...
11AA04... (3 Replies)