Getting A List of KEYIDS

Jeffrey Thompson
Wed, 22 Sep 1999 06:37:47 -0400

Hello one and all.  I'm determining keyids of encrypted messages.  I just
want the program to return
a list of keyids.  Here is my offering below.  I'm sure the users on the
list can improve upon it.  I would
like to see your improvements.

Thank you.
Jeffrey Thompson
Thompson Internet Communications, Inc.

# : return just the keyids that the file was encrypted to
if ($#ARGV != 0) {
    die "usage: encrypted-file\n";
system "gpg --batch --decrypt --status-fd 1 $ARGV[0]  > tmp$$ 2> /dev/null";
open (GPG_OUT,"<tmp$$") || die "tmp$$: $!\n";

# [GNUPG:]ENC_TO  <long keyid>  <keytype>  <keylength>
# [GNUPG:] ENC_TO 123455E815EE4B29 16 0
while(<GPG_OUT>) {
    if(/^\[GNUPG\:\] ENC_TO (\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w) (\d+) (\d+)/) {
        print "$1\n";
unlink "tmp$$";