#passphrase #password

pinentry

API for interacting with pinentry binaries

4 releases (breaking)

new 0.3.0 Jan 11, 2021
0.2.0 Jul 13, 2020
0.1.0 Jan 30, 2020
0.0.0 Jan 12, 2020

#76 in Command-line interface

Download history 54/week @ 2020-09-25 110/week @ 2020-10-02 68/week @ 2020-10-09 298/week @ 2020-10-16 210/week @ 2020-10-23 516/week @ 2020-10-30 264/week @ 2020-11-06 353/week @ 2020-11-13 627/week @ 2020-11-20 185/week @ 2020-11-27 204/week @ 2020-12-04 104/week @ 2020-12-11 144/week @ 2020-12-18 666/week @ 2020-12-25 406/week @ 2021-01-01 777/week @ 2021-01-08

1,466 downloads per month
Used in 3 crates

MIT/Apache

29KB
482 lines

pinentry

pinentry is a library for interacting with the pinentry binaries available on various platforms.

Usage

Add this line to your Cargo.toml:

pinentry = "0.3"

See the documentation for examples.

pinentry requires Rust version 1.44 or greater.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

pinentry is a library for interacting with the pinentry binaries available on various platforms.

Examples

Request passphrase or PIN

use pinentry::PassphraseInput;
use secrecy::SecretString;

let passphrase = if let Some(mut input) = PassphraseInput::with_default_binary() {
    // pinentry binary is available!
    input
        .with_description("Enter new passphrase for FooBar")
        .with_prompt("Passphrase:")
        .with_confirmation("Confirm passphrase:", "Passphrases do not match")
        .interact()
} else {
    // Fall back to some other passphrase entry method.
    Ok(SecretString::new("a better passphrase than this".to_owned()))
}?;
# Ok::<(), pinentry::Error>(())

Ask user for confirmation

use pinentry::ConfirmationDialog;

if let Some(mut input) = ConfirmationDialog::with_default_binary() {
    input
        .with_ok("Definitely!")
        .with_not_ok("No thanks")
        .with_cancel("Maybe later")
        .confirm("Would you like to play a game?")?;
};
# Ok::<(), pinentry::Error>(())

Display a message

use pinentry::MessageDialog;

if let Some(mut input) = MessageDialog::with_default_binary() {
    input.with_ok("Got it!").show_message("This will be shown with a single button.")?;
};
# Ok::<(), pinentry::Error>(())

Dependencies

~1.3–1.8MB
~39K SLoC