Compute a string's adler32 checksum

Here is an example to calculate adler32 crc for a string :

#!/usr/bin/perl -w
use Compress::Zlib;        # for adler32()

my $crc;
my $string="";
print "Calculating checksum for $string ...\n";
$crc = adler32($string,$crc);

Of course, it's easy to modify the script a bit to compute a input string.

Run and see

Calculating checksum for

Compute a file adler32 checksum

As for how to calculate adler32 for a file, do it this way.


use Compress::Zlib;

while(<>) {
       printf("%x %s\n",$crc,$filename);

Run and see

$./ ./
64712c9d ./

Perl Adler32 Module

Another way is to use perl module

use Digest::Adler32

It should be pretty much similar with the ways I mentioned compute a file or string md5sum in perl



Comments powered by CComment