Skip Menu |

This queue is for tickets about the Digest-CRC CPAN distribution.

Report information
The Basics
Id: 72385
Status: resolved
Priority: 0/
Queue: Digest-CRC

People
Owner: OLIMAUL [...] cpan.org
Requestors: dkg [...] fifthhorseman.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Digest::CRC::b64digest broken/wrong
Date: Sat, 12 Nov 2011 14:13:16 -0500
To: bug-Digest-CRC [...] rt.cpan.org, submit [...] bugs.debian.org
From: Daniel Kahn Gillmor <dkg [...] fifthhorseman.net>
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);
Download (untitled)
application/pgp-signature 965b

Message body not shown because it is not plain text.

Hi, thanks for the info. I fixed the base64 encoding routine. It is part of version 0.18 which I uploaded a few minutes ago. Oliver