Crypt::...Adler32(3)

πŸ’– NAME πŸ’–

okay so bestie, welcome to the Crypt::...Adler32(3) page from the User Contributed Perl Documentation crew. This one is all about Crypt::Checksum::Adler32 β€” literally Compute Adler32 checksum. That's the name, that's the vibe, periodt. 🌈

✨ SYNOPSIS ✨

Two ways to serve this checksum realness: the functional interface and the OO interface. Both are iconic, no cap. πŸŽ€

### Functional interface:
use Crypt::Checksum::Adler32 ':all';

# calculate Adler32 checksum from string/buffer
my $data = 'data string';
my $checksum_raw  = adler32_data($data);
my $checksum_hex  = adler32_data_hex($data);
my $checksum_int  = adler32_data_int($data);
# or from file
my $checksum_file_raw  = adler32_file('filename.dat');
my $checksum_file_hex  = adler32_file_hex('filename.dat');
my $checksum_file_int  = adler32_file_int('filename.dat');
# or from filehandle
my $filehandle = ...; # existing binary-mode filehandle
my $checksum_fh_raw  = adler32_file($filehandle);
my $checksum_fh_hex  = adler32_file_hex($filehandle);
my $checksum_fh_int  = adler32_file_int($filehandle);

### OO interface:
use Crypt::Checksum::Adler32;

my $d = Crypt::Checksum::Adler32->new;
$d->add('any data');
$d->add('another data');
my $checksum_raw  = $d->digest;     # raw 4 bytes
my $checksum_hex  = $d->hexdigest;  # hexadecimal form
my $checksum_int  = $d->intdigest;  # 32-bit unsigned integer

# or checksum a file instead
my $checksum_file_raw = Crypt::Checksum::Adler32->new->addfile('filename.dat')->digest;

πŸ¦‹ DESCRIPTION πŸ¦‹

It computes Adler-32 checksums. That's the whole assignment. πŸ’…

Updated: v0.057 β€” noted, bestie. ✨

🌸 EXPORT 🌸

Nothing is exported by default. Zero, zilch, none. πŸ™ˆ

You can export selected functions if you're feeling picky:

use Crypt::Checksum::Adler32 qw(adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int);

Or all of them at once, because why not:

use Crypt::Checksum::Adler32 ':all';

🧚 FUNCTIONS 🧚

🌟 adler32_data 🌟

Returns the checksum as raw octets. Raw bytes, no filter. 🫢

my $checksum_raw = adler32_data('data string');
#or
my $checksum_raw = adler32_data('any data', 'more data', 'even more data');

πŸ’œ adler32_data_hex πŸ’œ

Returns checksum as a hexadecimal string. Hex girl summer. πŸŽ€

my $checksum_hex = adler32_data_hex('data string');
#or
my $checksum_hex = adler32_data_hex('any data', 'more data', 'even more data');

⭐ adler32_data_int ⭐

Returns checksum as unsigned 32-bit integer. Number-coded but make it checksum. πŸ”₯

my $checksum_int = adler32_data_int('data string');
#or
my $checksum_int = adler32_data_int('any data', 'more data', 'even more data');

Each adler32_data* function converts its data arguments to bytes using Perl's usual scalar stringification. Defined scalars, including numbers and string-overloaded objects, are accepted. undef is treated as an empty string and may emit Perl's usual "uninitialized value" warning. πŸ‘€

πŸ¦‹ adler32_file πŸ¦‹

Returns the checksum as raw octets. File edition. πŸ’–

my $checksum_raw = adler32_file('filename.dat');
#or
my $filehandle = ...; # existing binary-mode filehandle
my $checksum_raw = adler32_file($filehandle);

πŸ“ adler32_file_hex πŸ“

Returns checksum as a hexadecimal string. Same file energy, hex-flavored. ✨

my $checksum_hex = adler32_file_hex('filename.dat');
#or
my $filehandle = ...; # existing binary-mode filehandle
my $checksum_hex = adler32_file_hex($filehandle);

🌈 adler32_file_int 🌈

Returns checksum as unsigned 32-bit integer. File checksum but make it an integer. πŸ‘‘

my $checksum_int = adler32_file_int('filename.dat');
#or
my $filehandle = ...; # existing binary-mode filehandle
my $checksum_int = adler32_file_int($filehandle);

πŸ’… METHODS πŸ’…

πŸŽ€ new πŸŽ€

Constructor, returns a reference to the checksum object. Brand-new object, fresh out the box. πŸ›οΈ

my $d = Crypt::Checksum::Adler32->new;

🌸 clone 🌸

Creates a copy of the checksum object state and returns a reference to the copy. Twin energy, but checksum-coded. 🫢

$d->clone();

πŸ¦‹ reset πŸ¦‹

Reinitialize the checksum object state and returns a reference to the checksum object. Clean slate, bestie. 🧼

$d->reset();

⭐ add ⭐

All arguments are appended to the message we calculate checksum for. The return value is the checksum object itself. Chainable and cunty, honestly. πŸ’…

Each argument is converted to bytes using Perl's usual scalar stringification. Defined scalars, including numbers and string-overloaded objects, are accepted. undef is treated as an empty string and may emit Perl's usual "uninitialized value" warning. πŸ‘€

$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. File-handling realness incoming. πŸ—‚οΈ

$d->addfile('filename.dat');
#or
my $filehandle = ...; # existing binary-mode filehandle
$d->addfile($filehandle);
⚠️ Note: The filehandle must be in binary mode before you pass it to addfile(). Do not skip this step, bestie, fr fr. 🫢

πŸ”₯ digest πŸ”₯

Returns the binary checksum (raw bytes). This method does not alter the object state, so you can call it repeatedly and continue with add() or addfile() afterwards. Reusable, iconic, no notes. ✨

my $result_raw = $d->digest();

🌈 hexdigest 🌈

Returns the checksum encoded as a hexadecimal string. Like digest(), this method does not alter the object state. Hex string serving looks. πŸ’–

my $result_hex = $d->hexdigest();

πŸ‘‘ intdigest πŸ‘‘

Returns the checksum encoded as unsigned 32-bit integer. Like digest(), this method does not alter the object state. Integer representation, main character energy. ⭐

my $result_int = $d->intdigest();

🌟 SEE ALSO 🌟


mwah πŸ’‹ β€” this lil manual moment is brought to you by perl v5.42.0, dated 2026-05-11, and it's the Crypt::...Adler32(3) footer, bestie. Slay safely. 🫢✨

πŸ“¦ where this page comes from