Package: libdigest-crc-perl
Version: 0.17-1

It appears that Digest::CRC::b64digest produces broken/wrong output as
of 0.17.

I think it's encoding the base 10 representation in ASCII of the digest,
rather than encoding the binary value.

The attached perl script demonstrates the problem.  Here's an example of
an invocation, and a demonstration of what i think it's doing:

dkg@pip:~/tmp$ ./b64broken
  dec: 293510564
 phex: 117e9da4
inhex: 117e9da4
 pb64: EX6dpA==
inb64: MjkzNTEwNT
0 dkg@pip:~/tmp$ printf MjkzNTEwNT | base64 -d
2935105base64: invalid input
1 dkg@pip:~/tmp$ printf EX6dpA== | base64 -d | hd
00000000  11 7e 9d a4                                       |.~..|
00000004
0 dkg@pip:~/tmp$ 

i can't make heads or tails of the internal _encode_base64 function,
unfortunately, so i'm not sure what to propose as a fix.

hth,

        --dkg

#!/usr/bin/perl -wT

use strict;
use warnings;
use Digest::CRC;
use MIME::Base64;

my $ctx = Digest::CRC->new(type=>'crc32');
my $data = 'abc1234' x 17;

$ctx->add($data);
printf("  dec: %d\n", $ctx->digest);
$ctx->add($data);
printf(" phex: %06x\n", $ctx->digest);
$ctx->add($data);
printf("inhex: %s\n", $ctx->hexdigest);
$ctx->add($data);
printf(" pb64: %s", encode_base64(pack("H*", sprintf("%08x", $ctx->digest))));
$ctx->add($data);
printf("inb64: %s\n", $ctx->b64digest);

Attachment: pgpz3LxsTP5nE.pgp
Description: PGP signature

Reply via email to