Getting A List of KEYIDS
Jeffrey Thompson
jeffrey@thompsonic.com
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.
http://www.thompsonic.com/
-------
#!/usr/local/bin/perl
# getkeyid.pl : return just the keyids that the file was encrypted to
#
if ($#ARGV != 0) {
die "usage: get_keyid.pl 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";
}
}
close(GPG_OUT);
unlink "tmp$$";