6 releases (breaking)

0.5.0 Aug 28, 2021
0.4.0 Aug 3, 2021
0.3.0 Jan 11, 2021
0.2.0 Jul 13, 2020
0.0.0 Jan 12, 2020

#471 in Authentication

Download history 1071/week @ 2023-12-07 1526/week @ 2023-12-14 451/week @ 2023-12-21 542/week @ 2023-12-28 1338/week @ 2024-01-04 1045/week @ 2024-01-11 1806/week @ 2024-01-18 1989/week @ 2024-01-25 1950/week @ 2024-02-01 875/week @ 2024-02-08 743/week @ 2024-02-15 664/week @ 2024-02-22 1279/week @ 2024-02-29 1731/week @ 2024-03-07 1017/week @ 2024-03-14 1130/week @ 2024-03-21

5,263 downloads per month
Used in 6 crates (5 directly)

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.5"

See the documentation for examples.

pinentry requires Rust version 1.51 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()))
}?;

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?")?;
};

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.")?;
};

Dependencies

~3–13MB
~136K SLoC