8 releases (breaking)

0.6.0 Nov 3, 2024
0.5.1 Aug 31, 2024
0.5.0 Aug 28, 2021
0.4.0 Aug 3, 2021
0.0.0 Jan 12, 2020

#179 in Authentication

Download history 756/week @ 2024-07-31 1159/week @ 2024-08-07 2245/week @ 2024-08-14 1803/week @ 2024-08-21 1226/week @ 2024-08-28 1162/week @ 2024-09-04 1046/week @ 2024-09-11 1258/week @ 2024-09-18 873/week @ 2024-09-25 1751/week @ 2024-10-02 726/week @ 2024-10-09 1788/week @ 2024-10-16 1085/week @ 2024-10-23 2100/week @ 2024-10-30 1676/week @ 2024-11-06 1694/week @ 2024-11-13

7,164 downloads per month
Used in 7 crates

MIT/Apache

31KB
533 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.6"

See the documentation for examples.

pinentry requires Rust version 1.60 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("a better passphrase than this".to_owned().into())
}?;

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

~2–11MB
~132K SLoC