Для подсчёта CRC32 использую следующий код:
Код: Выделить всё
use Digest::CRC qw(crc32);
my $h = 0;
open($fd, $f) or die "Can't open update file $f, $!";
my $crc = Digest::CRC->new(width => 32, poly => 0xedb88320, init => 0, xorout => 0xFFFFFFFF);
$crc->addfile($fd);
$h = $crc->digest;
print $crc->hexdigest;
close $fd;Ошибок никаких не выводится, но в выводе hexdigest всегда ноль, аналогичный код для SHA1 работает без проблем.
Вывод perldoc Digest::CRC не очень многословен.
Как решить эту проблему?
Спасибо.
Upd:
Похоже ответ здесь - perldoc Digest
..........
$ctx->digest
Return the binary digest for the message.
Note that the "digest" operation is effectively a destructive,
read-once operation. Once it has been performed, the $ctx object is
automatically "reset" and can be used to calculate another digest
value. Call $ctx->clone->digest if you want to calculate the
digest without resetting the digest state.
...........