The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME Mail::Exchange::CRC - implement the CRC algorithm used in RTF compression and the named property to index PPS streams

SYNOPSIS

    use Mail::Exchange::CRC;

    my $crc=Mail::Exchange::CRC::new();
    while (<FILE>) {
            $crc->append($_);
    }
    print $crc->value;

    print Mail::Exchange::CRC::crc($string);

DESCRIPTION

Mail::Exchange::CRC can be used in function mode or in object oriented mode. In function mode, you pass a string and get back the crc immediately, while in object mode, you initialize an object via new, then append data to the object as needed, and fetch the resulting value at the end.

The crc algorithm is documented in [MS-OXRTFCP], and happens to be the CRC-32 algorithm that is used in a lot of different places as well, for example in the the IEEE 802.3 Ethernet CRC specification.

new()

$crc=Mail::Exchange::CRC::new([string]) - initialize a new CRC value

Initialize a new CRC calculator, and calculate the CRC of string if provided.

append()

$crc->append(string)

Appends another string to a CRC, calculating the CRC of the two strings concatenated to each other

The following are supposed to be equal:

        $crc1=Mail::Exchange::CRC::new("hello world");


        $crc2=Mail::Exchange::CRC::new("hello");
        $crc2->append(" world");

value()

$crcval=$crc->value()

Returns the calculated value of the CRC.

crc()

$crc=Mail::Exchange::CRC::crc($string)

Calculates the CRC of a string in an easy-to-use, non-object-oriented way.