Skip to content

This CLI tool provides password hashing capabilities and password reset functionality for a user recorded in a database.

License

Notifications You must be signed in to change notification settings

unixtime/password-hasher-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FIle Router workflow

Password Hasher CLI Tool

This CLI tool provides password hashing capabilities and password reset functionality for a user recorded in a database. It allows for securely hashing passwords using bcrypt or argon2 and managing them within various databases, including MySQL, PostgreSQL, and SQLite. It can also operate in a standalone mode, where it simply hashes a password using a specified method without interacting with a database.

Requirements

  • Rust (latest stable release)
  • Cargo (Rust's package manager)

Supported Databases

  • PostgreSQL
  • MySQL/MariaDB
  • SQLite

On macOS using brew you need the following:

  • Postgres Lib
brew install libpq
  • MySQL Lib
brew install mysql-client

Setup Instructions

  1. Clone the Repository: Please install Rust and Cargo, then clone this repository to your local machine.
git clone https://github.com/unixtime/password-hasher-cli.git
cd password-hasher-cli

Environment Configuration

Rename example.env to .env and update the file to match your database credentials:

# PostgreSQL Database Configuration
POSTGRES_HOST='hostname'
POSTGRES_DB='database_name'
POSTGRES_USER='username'
POSTGRES_PASS='password'
POSTGRES_PORT=5432

# MySQL Database Configuration
MYSQL_HOST='hostname'
MYSQL_DB='database_name'
MYSQL_USER='username'
MYSQL_PASS='password'
MYSQL_PORT=3306

# SQLite Database Configuration
SQLITE_DATABASE_URL=sqlite:///path/to/your/database.db

Build the Application

Compile the application with Cargo:

cargo build --release

This command compiles the application and outputs the executable in target/release/.

Run the Application

To run the application, use the following command:

cargo run

Deployment

Copy the compiled executable to a directory in your PATH for easier execution:

cp target/release/password_hasher ~/bin/  # or any other directory in your PATH

Usage

Usage This application can be used in two modes: Standalone password hashing or database password management.

Standalone Password Hashing

To hash a password without interacting with a database:

password_hasher_cli --method argon2 --pass "SomePass"

Available methods for hashing are argon2 and bcrypt. By default, bcrypt is used if no method is specified.

Running the Application

Follow the on-screen prompts to select your database type, enter database credentials, and manage user passwords.

Test the Application SQLite

Creating the SQLite Users Table

Here’s an example of how you might set up a user table in SQLite to use with this tool:

sqlite3 users.db
CREATE TABLE users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    username TEXT NOT NULL,
    password TEXT NOT NULL
);

INSERT INTO users (username, password) VALUES ('tester', 'hashed_password');

Running the Tool with SQLite and SQLite Users Table Example

password_hasher_cli --method argon2 # or bcrypt

Password Hasher CLI
Enter database type (mysql, postgres, sqlite): sqlite
Enter table name: users
Enter the user ID or username to change password: 1
Please enter a password to hash (input will be hidden): 

Please confirm your password: 

Password updated successfully.

Additional Information This tool uses Diesel for ORM operations and bcrypt for password hashing. For more information on these dependencies, visit:

TODO:

  • Reset passwords in bulk in case of a data breach or migration to a new password hashing algorithm.
  • Add tests

License

This project is licensed under the MIT License - see the LICENSE file for details

About

This CLI tool provides password hashing capabilities and password reset functionality for a user recorded in a database.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages