[Pgp-tools-commit] r877 - in trunk: debian gpg-key2latex
Guilhem Moulin
guilhem-guest at moszumanska.debian.org
Thu Sep 8 15:53:49 UTC 2016
Author: guilhem-guest
Date: 2016-09-08 15:53:49 +0000 (Thu, 08 Sep 2016)
New Revision: 877
Modified:
trunk/debian/changelog
trunk/gpg-key2latex/gpg-key2latex
Log:
gpg-key2latex: Add an option '--qrcode-data' to specify the data to encode in a QR code.
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2016-08-26 13:21:47 UTC (rev 876)
+++ trunk/debian/changelog 2016-09-08 15:53:49 UTC (rev 877)
@@ -3,6 +3,8 @@
* caff: Show how to set $ENV{'PERL_MAILERS'} to specify a sendmail binary
(or use a sendmail-compatible MTA such as msmtp(1)). Credits to Ryan
Kavanagh's blog post.
+ * gpg-key2latex: Add an option '--qrcode-data' to specify the data to encode
+ in a QR code (default: "OPENPGP4FPR:%f").
-- Guilhem Moulin <guilhem at guilhem.org> Fri, 26 Aug 2016 15:11:09 +0200
Modified: trunk/gpg-key2latex/gpg-key2latex
===================================================================
--- trunk/gpg-key2latex/gpg-key2latex 2016-08-26 13:21:47 UTC (rev 876)
+++ trunk/gpg-key2latex/gpg-key2latex 2016-09-08 15:53:49 UTC (rev 877)
@@ -38,7 +38,7 @@
use GnuPG::Interface ();
my %options;
-GetOptions(\%options, qw/paper-size|p=s show-subkeys|s show-photo show-qrcode attr-height=i/) or pod2usage(2);
+GetOptions(\%options, qw/paper-size|p=s show-subkeys|s show-photo show-qrcode qrcode-data=s attr-height=i/) or pod2usage(2);
pod2usage(2) unless @ARGV;
my $LOCALE = Encode::find_encoding(langinfo(I18N::Langinfo::CODESET()));
@@ -213,7 +213,7 @@
close $fd;
}
- if ($options{'show-qrcode'}) {
+ if ($options{'show-qrcode'} or defined $options{'qrcode-data'}) {
$key{qrcode} = substr($key{fpr},-16).'-qrcode.pdf';
pipe my ($rfd, $wfd) or die "Can't pipe: $!";
if (my $pid = fork) {
@@ -228,7 +228,12 @@
close $rfd or die "Can't close: $!";
dup2 (fileno $wfd, 1);
close $wfd or die "Can't close: $!";
- exec qw/qrencode -i -lM -d300 -tEPS -o -/, "OPENPGP4FPR:$key{fpr}" or die "Can't exec: $!";
+ my $uri = $options{'qrcode-data'} // 'OPENPGP4FPR:%f';
+ $uri =~ s/%([fk%])/ $1 eq 'f' ? $key{fpr}
+ : $1 eq 'k' ? substr($key{fpr},-16)
+ : $1 eq '%' ? '%'
+ : die /ge;
+ exec qw/qrencode -i -lM -d300 -tEPS -o -/, $uri or die "Can't exec: $!";
}
}
@@ -480,11 +485,20 @@
=item B<--show-qrcode>
-Show a QR code of the OpenPGP key fingerprint (40 hexadecimal digits,
-without spaces), prefixed with the string "OPENPGP4FPR:". Note: This
+Show a QR code of the string specified by B<--qrcode-data>. Note: This
writes PDF files to the current directory.
Requires qrencode(1) and epstopdf(1).
+=item B<--qrcode-data=>I<string>
+
+The data to encode in a QR code (implies B<--show-qrcode>). The string
+"%f" is expanded to the OpenPGP key fingerprint (40 hexadecimal digits,
+without spaces); "%k" is expanded to the long (16 hexadecimal digits)
+key ID; "%%" is replaced by a single "%".
+
+The default data to encode, if B<--qrcode-data> is not specified, is the
+string "OPENPGP4FPR:%f".
+
=item B<--attr-height>
The height, in number of lines, of the photo and QR code. The default
More information about the Pgp-tools-commit
mailing list