Struct gpgme::context::Context [] [src]

#[must_use]
pub struct Context(_);

A context for cryptographic operations

Methods

impl Context
[src]

Uses the specified provider to handle passphrase requests for the duration of the closure.

Examples

use std::io::prelude::*;

use gpgme::{Context, PassphraseRequest, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp).unwrap();
ctx.with_passphrase_provider(|_: PassphraseRequest, out: &mut Write| {
    try!(out.write_all(b"some passphrase"));
    Ok(())
}, |mut ctx| {
    // Do something with ctx requiring a passphrase, for example decryption
});

Returns the public key with the specified fingerprint, if such a key can be found. Otherwise, an error is returned.

Returns the secret key with the specified fingerprint, if such a key can be found. Otherwise, an error is returned.

Returns an iterator for a list of all public keys matching one or more of the specified patterns.

Returns an iterator for a list of all secret keys matching one or more of the specified patterns.

Encrypts a message for the specified recipients.

Examples

use gpgme::{Context, Data, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp).unwrap();
let key = ctx.find_key("some pattern").unwrap();
let (mut plaintext, mut ciphertext) = (Data::new().unwrap(), Data::new().unwrap());
ctx.encrypt(Some(&key), &mut plaintext, &mut ciphertext).unwrap();

Encrypts and signs a message for the specified recipients.

Examples

use gpgme::{Context, Data, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp).unwrap();
let key = ctx.find_key("some pattern").unwrap();
let (mut plaintext, mut ciphertext) = (Data::new().unwrap(), Data::new().unwrap());
ctx.sign_and_encrypt(Some(&key), &mut plaintext, &mut ciphertext).unwrap();

Decrypts a message.

Examples

use gpgme::{Context, Data, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp).unwrap();
let mut cipher = Data::load("some file").unwrap();
let mut plain = Data::new().unwrap();
ctx.decrypt(&mut cipher, &mut plain).unwrap();

Decrypts and verifies a message.

Examples

use gpgme::{Context, Data, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp).unwrap();
let mut cipher = Data::load("some file").unwrap();
let mut plain = Data::new().unwrap();
ctx.decrypt_and_verify(&mut cipher, &mut plain).unwrap();

Trait Implementations

impl Drop for Context
[src]

A method called when the value goes out of scope. Read more

impl Debug for Context
[src]

Formats the value using the given formatter.