#password #getpass #security #read #pass

readpass

A tiny library for reading passwords without displaying them on the terminal

3 stable releases

1.0.2 Mar 12, 2025
1.0.1 Mar 3, 2025
1.0.0 Feb 27, 2025

#265 in Command-line interface

Download history 263/week @ 2025-02-26 52/week @ 2025-03-05 136/week @ 2025-03-12

451 downloads per month

Apache-2.0

13KB
180 lines

readpass

CI crates.io MSRV crates.io downloads license
docs.rs

A tiny library for reading passwords without displaying them on the terminal. It's similar to the C function getpass() or Python's getpass module.

Usage

Read a password without displaying it on the terminal:

let passwd = readpass::from_tty()?;

If you want to display a prompt, print it to stdout or stderr before reading:

use std::io::{self, Write};

write!(io::stderr(), "Please enter a password: ")?;
let passwd = readpass::from_tty()?;

Strings returned by readpass are wrapped in Zeroizing to ensure the password is zeroized from memory after it's Dropped.

Docs: https://docs.rs/readpass.

License

The source code is released under the Apache 2.0 license.

This is a fork of rpassword by Conrad Kleinespel. The original library appears unmaintained, and rolls its own version of zeroize in rtoolbox. This crate aims to change that.

Dependencies

~0–8MB
~54K SLoC