std.c: Improve some comments
[sunny256-utils.git] / degpg
blob4b026b621795f7efc81fd14370f8b62edef05b48
1 #!/usr/bin/env perl
3 # degpg
4 # File ID: 79505b44-1939-11de-82e7-000475e441b9
5 # Konverterer PGP/GPG-armor fra stdin. Kan ta mange om gangen.
7 use strict;
8 use warnings;
10 my $pwd_str = `head -1 /dev/tty`;
11 my $gpg_header = "-----BEGIN PGP MESSAGE-----";
12 my $gpg_footer = "-----END PGP MESSAGE-----";
14 $| = 1;
16 while (<>) {
17 if (/^$gpg_header$/) {
18 open(gpgFP, "|gpg -q --passphrase-fd 0 2>/dev/null") || die("Kan ikke åpne gpg-pipe: $!");
19 print(gpgFP "$pwd_str\n$gpg_header\n");
20 while (<>) { # Satser på at GPG kun tar meldingen og at den ikke spiser opp hele stdin.
21 print(gpgFP "$_");
22 /^$gpg_footer$/ && (close(gpgFP), last);
24 } else {
25 print;