The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Crypt::Checksum::CRC32 - Compute CRC32 checksum

SYNOPSIS

use Crypt::Checksum::CRC32;

$d = Crypt::Checksum::CRC32->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$checksum_raw = $d->digest;     # raw bytes
$checksum_hex = $d->hexdigest;  # hexadecimal form

DESCRIPTION

Calculating CRC32 checksums (OO interface);

Since: CryptX-0.032

METHODS

new

Constructor, returns a reference to the checksum object.

$d = Crypt::Checksum::CRC32->new;

clone

Creates a copy of the checksum object state and returns a reference to the copy.

$d->clone();

reset

Reinitialize the checksum object state and returns a reference to the checksum object.

$d->reset();

add

All arguments are appended to the message we calculate checksum for. The return value is the checksum object itself.

$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');

addfile

The content of the file (or filehandle) is appended to the message we calculate checksum for. The return value is the checksum object itself.

$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);

BEWARE: You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.

digest

Returns the binary checksum (raw bytes).

$result_raw = $d->digest();

hexdigest

Returns the checksum encoded as a hexadecimal string.

$result_hex = $d->hexdigest();

SEE ALSO