use std::io;
use clipass_rs::CliPass;
fn notification(block: u8) {
println!();
println!("[*] Executing Block: Example Nr. {}..", block);
}
fn main() -> io::Result<()> {
{
notification(1);
const CUSTOM_LABEL: &str = "Please enter your password:";
let mut session = CliPass::new();
session.set_prompt_label(CUSTOM_LABEL);
let password = session.launch_prompt()?;
if password.is_empty() {
return Err(io::Error::new(io::ErrorKind::InvalidData, "Please provide a password!"));
}
println!("Cleartext Password: {}", password);
println!("Sha256 Password Hash: {}", session.hash_sha256_internal());
}
{
notification(2);
const HASH_256: &str = "405f42005704da932ea8a4ad1f1e8c26e751af0316caa1e7e4bef4af4e2d93fe";
let mut session = CliPass::new();
session.set_prompt_mask_token('#');
session.set_no_label(); session.launch_prompt()?;
assert_eq!(session.hash_sha256_internal(), HASH_256);
}
Ok(())
}