use Mail::Exchange::CRC; my $crc=Mail::Exchange::CRC::new(); while (<FILE>) { $crc->append($_); } print $crc->value; print Mail::Exchange::CRC::crc($string);
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.
new
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.
$crc=Mail::Exchange::CRC::new([string]) - initialize a new CRC value
Initialize a new CRC calculator, and calculate the CRC of string if provided.
string
$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");
$crcval=$crc->value()
Returns the calculated value of the CRC.
$crc=Mail::Exchange::CRC::crc($string)
Calculates the CRC of a string in an easy-to-use, non-object-oriented way.
To install Mail::Exchange::CRC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mail::Exchange::CRC
CPAN shell
perl -MCPAN -e shell install Mail::Exchange::CRC
For more information on module installation, please visit the detailed CPAN module installation guide.