Skip to content

Commit fa3402a

Browse files
author
Benjamin Trott
committed
pod updates -> README update.
1 parent a78bfd2 commit fa3402a

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

MANIFEST

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ inc/Module/Install/ReadmeFromPod.pm
1313
inc/Module/Install/Repository.pm
1414
inc/Module/Install/Win32.pm
1515
inc/Module/Install/WriteAll.pm
16+
inc/Sub/Uplevel.pm
17+
inc/Test/Exception.pm
1618
lib/Crypt/OpenPGP.pm
1719
lib/Crypt/OpenPGP/Armour.pm
1820
lib/Crypt/OpenPGP/Buffer.pm
@@ -76,6 +78,5 @@ t/samples/gpg/ring.pub
7678
t/samples/gpg/ring.sec
7779
t/samples/message.asc
7880
t/test-common.pl
79-
xt/perlcritic.t
8081
xt/pod.t
8182
xt/synopsis.t

README

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,46 @@ NAME
33

44
SYNOPSIS
55
my $pgp = Crypt::OpenPGP->new;
6+
7+
# Given an input stream (could be a signature, ciphertext, etc),
8+
# do the "right thing" to it.
9+
my $message_body; $message_body .= $_ while <STDIN>;
610
my $result = $pgp->handle( Data => $message_body );
711

12+
# Create a detached, ASCII-armoured signature of $file using the
13+
# secret key $key_id, protected with the passphrase $pass.
14+
my $file = 'really-from-me.txt';
15+
my $key_id = '...';
16+
my $pass = 'foo bar';
817
my $signature = $pgp->sign(
9-
Filename => $file,
10-
KeyID => $key_id,
11-
Passphrase => $pass,
12-
Detach => 1,
13-
Armour => 1,
14-
);
15-
16-
my $valid = $pgp->verify(
17-
Signature => $signature,
18-
Files => [ $file ],
19-
);
20-
18+
Filename => $file,
19+
KeyID => $key_id,
20+
Passphrase => $pass,
21+
Detach => 1,
22+
Armour => 1,
23+
);
24+
25+
# Verify the detached signature $signature, which should be of the
26+
# source file $file.
27+
my $is_valid = $pgp->verify(
28+
Signature => $signature,
29+
Files => [ $file ],
30+
);
31+
32+
# Using the public key associated with $key_id, encrypt the contents
33+
# of the file $file, and ASCII-armour the ciphertext.
2134
my $ciphertext = $pgp->encrypt(
22-
Filename => $file,
23-
Recipients => $key_id,
24-
Armour => 1,
25-
);
35+
Filename => $file,
36+
Recipients => $key_id,
37+
Armour => 1,
38+
);
2639

40+
# Decrypt $ciphertext using the secret key used to encrypt it,
41+
# which key is protected with the passphrase $pass.
2742
my $plaintext = $pgp->decrypt(
28-
Data => $ciphertext,
29-
Passphrase => $pass,
30-
);
43+
Data => $ciphertext,
44+
Passphrase => $pass,
45+
);
3146

3247
DESCRIPTION
3348
*Crypt::OpenPGP* is a pure-Perl implementation of the OpenPGP

0 commit comments

Comments
 (0)