diff options
author | Florian Pritz <bluewind@xinu.at> | 2019-06-01 11:50:41 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2019-06-01 11:50:41 +0200 |
commit | 6677b0b33fb573ee6a05e1caf16ca545d771993f (patch) | |
tree | d90e0e12d0c8b0815a46ffbc4e5d303b0d7f40fd /import-autocrypt | |
parent | d1e86af42349e13c58ccfade6f852e8413a08d29 (diff) | |
download | bin-6677b0b33fb573ee6a05e1caf16ca545d771993f.tar.gz bin-6677b0b33fb573ee6a05e1caf16ca545d771993f.tar.xz |
Add import-autocrypt
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'import-autocrypt')
-rwxr-xr-x | import-autocrypt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/import-autocrypt b/import-autocrypt new file mode 100755 index 0000000..5a38ee3 --- /dev/null +++ b/import-autocrypt @@ -0,0 +1,27 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Data::Dumper; +use MIME::Base64; + +my $headers = {}; +my $last_key; + +while (my $line = <STDIN>) { + # stop parsing once we reach the body + last if $line =~ /^$/; + + if ($line =~ /^(?<key>[^:]+): (?<value>.*)$/) { + $last_key = lc($+{key}); + $headers->{$last_key} = $+{value}; + } elsif (defined($last_key) && $line =~ /^\s+(?<value>.*)$/) { + $headers->{$last_key} .= $+{value}; + } +} + +my $autocrypt = {split(/=|;\s*/, $headers->{autocrypt})}; +my $keydata = decode_base64($autocrypt->{keydata}); +open my $gpg, '|-', qw(gpg --import); +print $gpg $keydata; +close $gpg; |