rpassword 0.4.0

Read passwords in console applications.
Documentation

Rustastic Password

Build Status Build status

This Rust package allows you to safely read passwords from standard input in a console application.

You can build the documentation with cargo doc or view it online.

The source code is released under the Apache 2.0 license.

I'd appreciate feedback if you use this library :-)

Usage

Add rpassword as a dependency in Cargo.toml:

[dependencies]
rpassword = "0.4"

Import the rpassword crate and use the promt_password_stdout() to show a message on stdout and read a password into a String:

extern crate rpassword;

fn main() {
    let pass = rpassword::prompt_password_stdout("Password: ").unwrap();
    println!("Your password is {}", pass);
}

You can also read a password without prompting:

extern crate rpassword;

fn main() {
    let pass = rpassword::read_password().unwrap();
    println!("Your password is {}", pass);
}

Finally, you can read strings with a single line, and without the terminating newline that read_line would add:

extern crate rpassword;

fn main() {
    let response = rpassword::read_response().unwrap();
    println!("Your response is {}", response);
}

Check examples/example.rs for a few more examples.

Contributors