htauth 0.1.0

A library for managing htpasswd files
Documentation

A lightweight alternative to Apache's htpasswd tool.

This library provides functionality to create, read, and modify htpasswd files with support for bcrypt, SHA-256, SHA-512, and APR1-MD5 password hashing algorithms.

Example

use htauth::{Htpasswd, HashAlgorithm};

# fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create or open an htpasswd file
let mut htpasswd = Htpasswd::open(".htpasswd")?;

// Add a new user
htpasswd.add_user("alice", "password123", HashAlgorithm::Bcrypt)?;

// Verify a user's password
if htpasswd.verify_user("alice", "password123")? {
    println!("Password correct!");
}

// List all users
for user in htpasswd.list_users() {
    println!("{}", user);
}

// Save changes
htpasswd.save()?;
# Ok(())
# }