From 5fbd33f1b7f56331894151118046b00fb46e6d3f Mon Sep 17 00:00:00 2001 From: bongosmurf Date: Fri, 25 Nov 2011 20:42:01 +0100 Subject: [PATCH 1/2] added Crypt::OpenPGP::Certificate->key_id_hex_short() --- lib/Crypt/OpenPGP/Certificate.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Crypt/OpenPGP/Certificate.pm b/lib/Crypt/OpenPGP/Certificate.pm index 72d344b..804282e 100644 --- a/lib/Crypt/OpenPGP/Certificate.pm +++ b/lib/Crypt/OpenPGP/Certificate.pm @@ -105,6 +105,8 @@ sub key_id { sub key_id_hex { uc unpack 'H*', $_[0]->key_id } +sub key_id_hex_short { uc substr( unpack( 'H*', $_[0]->key_id ), -8, 8) } + sub fingerprint { my $cert = shift; unless ($cert->{fingerprint}) { @@ -504,8 +506,12 @@ Returns the key ID. =head2 $cert->key_id_hex -Returns the key ID as a hex string. +Returns the long key ID as a hex string. + +=head2 $cert->key_id_hex_short +Returns the short key ID as a hex string. + =head2 $cert->key Returns the algorithm-specific portion of the certificate, the public From a3200ccf4f57113b588d6b675b11df81eec3b697 Mon Sep 17 00:00:00 2001 From: bongosmurf Date: Fri, 25 Nov 2011 20:45:21 +0100 Subject: [PATCH 2/2] Added Crypt::OpenPGP::Signature->key_id_hex() Crypt::OpenPGP::Signature->key_id_hex_short() --- lib/Crypt/OpenPGP/Signature.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Crypt/OpenPGP/Signature.pm b/lib/Crypt/OpenPGP/Signature.pm index 7fe236c..06b1496 100644 --- a/lib/Crypt/OpenPGP/Signature.pm +++ b/lib/Crypt/OpenPGP/Signature.pm @@ -19,6 +19,10 @@ sub key_id { $sig->{key_id}; } +sub key_id_hex { uc unpack 'H*', $_[0]->key_id } + +sub key_id_hex_short { uc substr( unpack( 'H*', $_[0]->key_id ), -8, 8) } + sub timestamp { my $sig = shift; $sig->{version} < 4 ? @@ -405,6 +409,14 @@ This is a standard OpenPGP signature. Returns the ID of the key that created the signature. +=head2 $sig->key_id_hex + +Returns the long hexadecimal ID of the key that created the signature. + +=head2 $sig->key_id_hex_short + +Returns the short hexadecimal ID of the key that created the signature. + =head2 $sig->timestamp Returns the time that the signature was created in Unix epoch time (seconds