NAME
Strihng::CRC32C - Castagnoli CRC
SYNOPSIS
use String::CRC32C; # does not export anything by default
use String::CRC32C 'crc32c';
$crc = crc32 "some string";
$crc = crc32 "some string", $initvalue;
DESCRIPTION
This module calculates the Castagnoli CRC32 variant (polynomial
0x11EDC6F41).
It is used by iSCSI, SCTP, BTRFS, ext4, leveldb, x86 CPUs and others.
This module uses an optimized implementation for SSE 4.2 targets (GCC
and compatible supported, SSE 4.2 must be enabled in your Perl) and the
SlicingBy8 algorithm for anything else.
$crc32c = crc32c $string[, $initvalue]
Calculates the CRC32C value of the given $string and returns it as a
32 bit unsigned integer.
To get the common hex form, use one of:
sprintf "%08x", crc32c $string
unpack "H*", pack "L>", crc32c $string
A seed/initial crc value can be given as second argument. Note that
both the initial value and the result value are inverted
(pre-inversion and post-inversion), e.g. a common init value of -1
from other descriptions needs to be given as 0 (or "~-1").
This allows easy chaining, e.g.
(crc32c "abcdefghi") eq (crc32 "ghi", crc32 "def", crc32 "abc)
$impl = $String::CRC32C::IMPL
Returns a string indicating the implementation that will be used.
Currently either "SlicingBy8" for the portable implementation or
"IntelCSSE42" for the SSE 4.2 optimized intel version.
AUTHOR
Marc Lehmann <schmorp@schmorp.de>
http://home.schmorp.de/
CRC32C code by various sources, ported from
https://github.com/htot/crc32c, see sources for details.