#password #getpass #security #read-password

rpassword

Read passwords in console applications (unix, windows, macos, wasm)

47 releases (29 stable)

Uses new Rust 2024

7.5.4 May 31, 2026
7.5.1 Apr 29, 2026
7.4.0 Apr 20, 2025
7.3.1 Nov 11, 2023
0.0.2 Mar 4, 2015

#6 in Authentication

Download history 467954/week @ 2026-03-25 495809/week @ 2026-04-01 492175/week @ 2026-04-08 500393/week @ 2026-04-15 505588/week @ 2026-04-22 515218/week @ 2026-04-29 558148/week @ 2026-05-06 688864/week @ 2026-05-13 637872/week @ 2026-05-20 677242/week @ 2026-05-27 689218/week @ 2026-06-03 660016/week @ 2026-06-10 694488/week @ 2026-06-17 656721/week @ 2026-06-24 614657/week @ 2026-07-01 564000/week @ 2026-07-08

2,645,880 downloads per month
Used in 2,205 crates (1,135 directly)

Apache-2.0

57KB
1.5K SLoC

Rustastic Password

rpassword makes it easy to read passwords from Rust code in console applications on all platforms, Unix, Windows, WASM and more. It's similar to Linux's C function getpass() or Python's getpass module.

rpassword logo and headline

Usage

Add rpassword as a dependency in Cargo.toml:

[dependencies]
rpassword = "7.5"

Then use it in your code:

use std::io::{Cursor, Write};
use rpassword::{ConfigBuilder};

fn main() {
    // By default, reads and writes to the console, hides password as it is typed 
    let password = rpassword::prompt_password("Your password: ").unwrap();
    println!("Your password is {}", password);
    
    // Behavior is customizable to accommodate custom use-cases and testing
    // See documentation for more details
     let config = rpassword::ConfigBuilder::new()
         .input_data("my-password\n")
         .output_discard()
         .password_feedback_mask('*')
         .build();
    
     let password = rpassword::read_password_with_config(config).unwrap();
     println!("Your password is {}", password);
}

See examples and docs at https://docs.rs/rpassword.

See the upgrade path in UPGRADE.md.

License

The source code is released under the Apache 2.0 license.

Dependencies

~0–9.5MB
~49K SLoC