| Crates.io | clipass_rs |
| lib.rs | clipass_rs |
| version | 0.1.0 |
| created_at | 2025-07-14 12:56:16.887599+00 |
| updated_at | 2025-07-14 12:56:16.887599+00 |
| description | Library for masked CLI input reading |
| homepage | |
| repository | https://github.com/f42h/clipass_rs |
| max_upload_size | |
| id | 1751661 |
| size | 32,971 |
This library provides the basic functionality for masking the input reading
of a console application. By setting up the required needs, the custom prompt
won't reveal the input unless it is allowed to do so. The input can either
directly be accessed or hashed in (currently) sha256 and md5.
use clipass_rs::CliPass;
let mut session = CliPass::new();
pub fn set_prompt_label(&mut self, custom_label: &str)
pub fn set_no_label(&mut self)
pub fn set_no_visibility(&mut self)
pub fn set_prompt_mask_token(&mut self, custom_token: char)
pub fn launch_prompt(&mut self) -> io::Result<String>
use std::io;
use clipass_rs::CliPass;
fn main() {
const HASH_256: &str = "405f42005704da932ea8a4ad1f1e8c26e751af0316caa1e7e4bef4af4e2d93fe"; // correctpassword
let mut session = CliPass::new();
session.set_prompt_mask_token('#');
session.set_no_label(); // We don't want to display any prompt label
session.launch_prompt()?;
// Compare the required hash against the hashed password provided by the user
assert_eq!(session.hash_sha256_internal(), HASH_256);
}
/*
* Output:
* -------
* ############### <-- "invalidpassword"
*
* thread 'main' panicked at src/bin/main.rs:56:9:
* assertion `left == right` failed
* left: "5bd7f6cf3b61dd672341c7cc2baafd3e960b01ffef4509bb631b4b267e85b444"
* right: "405f42005704da932ea8a4ad1f1e8c26e751af0316caa1e7e4bef4af4e2d93fe"
*/
This project is published under the MIT license.