Scripting‎ > ‎Perl examples‎ > ‎

how to calculate adler32 in perl

Thank you for visiting this page, this page has been update in another link How to calculate adler32 in Perl
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);
Run it
Calculating checksum for

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


use Compress::Zlib;

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

try to run it
$./ ./
64712c9d ./

I think there could be a way to use module
use Digest::Adler32

It should be pretty much similar with the ways I mentioned for md5, but I haven't got chance to try it yet.