]> snippets.scripts.mit.edu Git - Scripts/git/.git/blame_incremental - barnowl/zcrypt.pl
zcrypt.pl: No need to replace BarnOwl’s builtin zcrypt anymore
[Scripts/git/.git] / barnowl / zcrypt.pl
... / ...
CommitLineData
1# This perl module adds a :decrypt command that uses barnowl's zcrypt
2# binary via Perl to decrypt zcrypt'd zephyrs after they have been
3# received.
4#
5# To use this code, type
6# :perl do '/mit/snippets/barnowl/zcrypt.pl'
7#
8
9use IPC::Open2;
10BarnOwl::new_command(decrypt => sub {
11 my $msg = BarnOwl::getcurmsg();
12 my $cmd = shift;
13 my @args = @_;
14 if (scalar @args == 0) {
15 @args = ('-c', $msg->class, '-i', $msg->instance);
16 }
17 my ($zo, $zi);
18 my $pid = open2($zo, $zi, 'athrun', 'barnowl', 'zcrypt', '-D', @args) or die "Couldn't launch zcrypt\n";
19 my $decrypted;
20 print $zi $msg->fields->[1] . "\n";
21 close $zi;
22 while (<$zo>) {
23 chomp;
24 last if $_ eq "**END**";
25 $decrypted .= "$_\n";
26 }
27 BarnOwl::popless_ztext($decrypted);
28 waitpid $pid, 0;
29 },
30 {summary => "Decrypt a zcrypted message once",
31 usage => "decrypt [args]",
32 description => "Invokes athrun barnowl zcrypt on the current message,\n
33using the class and instance to find the crypt key, and pops up the\n
34decrypted output. If args are specified, they are passed to zcrypt and the\n
35class and instance are ignored.\n\n
36SEE ALSO: zcrypt(1)"});
37
381;