diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-05-07 15:36:37 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-05-07 17:00:52 +0200 |
commit | 3eb554d0980ae788df2a07df609b77e01b7e57ce (patch) | |
tree | 1a36348c4e7dd5ec7b3f83b6ed5d93b80a0e200d /openpgp/examples | |
parent | 50b3ed9a61161761f20d134b13c2f8ac07698ea5 (diff) |
openpgp: Use a builder to construct Decryptor.
- See #498.
Diffstat (limited to 'openpgp/examples')
-rw-r--r-- | openpgp/examples/decrypt-with.rs | 5 | ||||
-rw-r--r-- | openpgp/examples/generate-encrypt-decrypt.rs | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/openpgp/examples/decrypt-with.rs b/openpgp/examples/decrypt-with.rs index 4360ddc0..09f44794 100644 --- a/openpgp/examples/decrypt-with.rs +++ b/openpgp/examples/decrypt-with.rs @@ -14,7 +14,7 @@ use crate::openpgp::parse::{ Parse, stream::{ DecryptionHelper, - Decryptor, + DecryptorBuilder, VerificationHelper, GoodChecksum, MessageStructure, @@ -42,7 +42,8 @@ pub fn main() { // Now, create a decryptor with a helper using the given Certs. let mut decryptor = - Decryptor::from_reader(p, io::stdin(), Helper::new(p, certs), None).unwrap(); + DecryptorBuilder::from_reader(io::stdin()).unwrap() + .with_policy(p, None, Helper::new(p, certs)).unwrap(); // Finally, stream the decrypted data to stdout. io::copy(&mut decryptor, &mut io::stdout()) diff --git a/openpgp/examples/generate-encrypt-decrypt.rs b/openpgp/examples/generate-encrypt-decrypt.rs index e735caed..7154ce0a 100644 --- a/openpgp/examples/generate-encrypt-decrypt.rs +++ b/openpgp/examples/generate-encrypt-decrypt.rs @@ -7,7 +7,7 @@ use crate::openpgp::cert::prelude::*; use crate::openpgp::crypto::SessionKey; use crate::openpgp::types::SymmetricAlgorithm; use crate::openpgp::serialize::stream::*; -use crate::openpgp::parse::stream::*; +use crate::openpgp::parse::{Parse, stream::*}; use crate::openpgp::policy::Policy; use crate::openpgp::policy::StandardPolicy as P; @@ -86,7 +86,8 @@ fn decrypt(p: &dyn Policy, }; // Now, create a decryptor with a helper using the given Certs. - let mut decryptor = Decryptor::from_bytes(p, ciphertext, helper, None)?; + let mut decryptor = DecryptorBuilder::from_bytes(ciphertext)? + .with_policy(p, None, helper)?; // Decrypt the data. io::copy(&mut decryptor, sink)?; |