Crate htauth

Crate htauth 

Source
Expand description

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};

// 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()?;

Structs§

Htpasswd
Represents an htpasswd file with user credentials.

Enums§

Apr1Md5Error
Errors that can occur during APR1-MD5 operations.
HashAlgorithm
Supported password hashing algorithms.
HashError
Errors that can occur during password hashing and verification.
HtpasswdError
Errors that can occur during htpasswd file operations.

Functions§

detect_algorithm
Detect the hash algorithm from a hash string.
hash_password
Hash a password using the specified algorithm.
verify_password
Verify a password against a hash.