Fellow Monks!

In trying to verify a PGP signature and determine the Key ID of the signing key, I have been stumped by the strange format I encountered in reading out that Key ID.

Expecting to find it in the usual hex format, I instead was offered 'key_id' => 'yp▒▒▒▒▒'. To me this is especially confusing as accoring to the docs when creating a signature, you are supposed to enter the Key-ID as an 8- or 16-digit hex number.

Here's a code snippet:

use Crypt::OpenPGP; ... my $pgp = Crypt::OpenPGP->new; my($userid,$sigobj) = $pgp->verify( Signature => $mailbody, Data => $mailbody, ); unless(defined $userid){ done(1,"Could not verify signature."); } printf("KeyID: 0x%x\nUserID:%s\n",$sigobj->key_id, $userid);

Output:

Argument "ypM-&M-^W^]M-^UM-\rM-^W" isn't numeric in printf at ./script.pl line 118.
KeyID: 0x0
UserID:Test Key <testkey@example.com>

How can I get the Key-ID in hex? Am I just not seeing it? I would be delighted to be enlightened. :-)

Update/Correction: Input of course would be an 8- or 16-digit hex no., not 10 as I previously wrote.


In reply to Stumped by Crypt::OpenPGP::Signature->key_id by mhi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.