summaryrefslogtreecommitdiffstats
path: root/openpgp/examples/encrypt-for.rs
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/examples/encrypt-for.rs')
-rw-r--r--openpgp/examples/encrypt-for.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/openpgp/examples/encrypt-for.rs b/openpgp/examples/encrypt-for.rs
index ef6486eb..d8c3affd 100644
--- a/openpgp/examples/encrypt-for.rs
+++ b/openpgp/examples/encrypt-for.rs
@@ -38,7 +38,7 @@ fn main() {
}).collect();
// Build a vector of recipients to hand to Encryptor.
- let mut recipients =
+ let recipients =
certs.iter()
.flat_map(|cert| {
cert.keys()
@@ -57,12 +57,8 @@ fn main() {
let message = Message::new(&mut sink);
// We want to encrypt a literal data packet.
- let mut encryptor = Encryptor::for_recipient(
- message, recipients.pop().expect("No encryption key found"));
- for r in recipients {
- encryptor = encryptor.add_recipient(r)
- }
- let encryptor = encryptor.build().expect("Failed to create encryptor");
+ let encryptor = Encryptor::for_recipients(message, recipients)
+ .build().expect("Failed to create encryptor");
let mut literal_writer = LiteralWriter::new(encryptor).build()
.expect("Failed to create literal writer");