This tutorial will guide you through building a simple password manager in Rust.
- Rust installed on your system
- Basic knowledge of Rust programming
- Cargo package manager
- Create a new Rust project:
cargo new hashpass
cd hashpass- Add the following dependencies to your
Cargo.toml:
[dependencies]
clap = { version = "4.4", features = ["derive"] }
bcrypt = "0.15"
thiserror = "1.0"- Create the basic project structure:
src/lib.rs: Core password hashing functionalitysrc/main.rs: CLI interface
The core functionality is implemented in lib.rs with two main functions:
hash_password: Takes a password string and number of rounds, returns a hashed passwordverify_password: Verifies a password against a hash
Example usage:
use hashpass::{hash_password, verify_password};
// Hash a password
let hashed = hash_password("mypassword", 12)?;
// Verify the password
let is_valid = verify_password("mypassword", &hashed)?;The project includes a command-line interface for:
- Hashing passwords
- Verifying passwords against existing hashes
Usage examples will be covered in the following sections...