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 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