Skip to main content

Hash Forge is a lightweight Python library designed to simplify the process of hashing and verifying data using a variety of secure hashing algorithms.

Project description

Hash Forge

PyPI version Build Status License: MIT Python Versions Downloads GitHub issues Project Status Code Style: Black Contributions welcome

Hash Forge is a lightweight Python library designed to simplify the process of hashing and verifying data using a variety of secure hashing algorithms.

Overview

Hash Forge is a flexible and secure hash management tool that supports multiple hashing algorithms. This tool allows you to hash and verify data using popular hash algorithms, making it easy to integrate into projects where password hashing or data integrity is essential.

Features

  • Multiple Hashing Algorithms: Supports bcrypt, Scrypt, Argon2, Blake2, PBKDF2, Whirlpool and RIPEMD-160.
  • Hashing and Verification: Easily hash strings and verify their integrity.
  • Rehash Detection: Automatically detects if a hash needs to be rehashed based on outdated parameters or algorithms.
  • Flexible Integration: Extendible to add new hashing algorithms as needed.

Installation

pip install hash-forge

Optional Dependencies

Hash Forge provides optional dependencies for specific hashing algorithms. To install these, use:

  • bcrypt support:

    pip install "hash-forge[bcrypt]"
    
  • Argon2 support:

    pip install "hash-forge[argon2]"
    
  • Whirlpool and RIPEMD-160 support:

    pip install "hash-forge[crypto]"
    
  • Blake3 support:

    pip install "hash-forge[blake3]"
    

Usage

Basic Example

from hash_forge import HashManager
from hash-forge.hashers import PBKDF2Hasher

# Initialize HashManager with PBKDF2Hasher
hash_manager = HashManager(PBKDF2Hasher())

# Hash a string
hashed_value = hash_manager.hash("my_secure_password")

# Verify the string against the hashed value
is_valid = hash_manager.verify("my_secure_password", hashed_value)
print(is_valid)  # Outputs: True

# Check if the hash needs rehashing
needs_rehash = hash_manager.needs_rehash(hashed_value)
print(needs_rehash)  # Outputs: False

Note: The first hasher provided during initialization of HashManager will be the preferred hasher used for hashing operations, though any available hasher can be used for verification.

Hashers

Currently supported hashers:

  • PBKDF2 (default)
  • bcrypt
  • Argon2
  • Scrypt
  • Blake2
  • Blake3
  • Whirlpool
  • RIPEMD-160

You can initialize HashManager with one or more hashers:

from hash_forge import HashManager
from hash_forge.hashers import (
    Argon2Hasher,
    BCryptSha256Hasher,
    Blake2Hasher,
    PBKDF2Sha256Hasher,
    Ripemd160Hasher,
    ScryptHasher,
    WhirlpoolHasher,
    Blake3Hasher
)

hash_manager = HashManager(
    PBKDF2Sha256Hasher(iterations=150_000),
    BCryptSha256Hasher(),
    Argon2Hasher(),
    ScryptHasher(),
    Ripemd160Hasher(),
    Blake2Hasher('MySecretKey'),
    WhirlpoolHasher(),
    Blake3Hasher()
  )

Verifying a Hash

Use the verify method to compare a string with its hashed counterpart:

is_valid = hash_manager.verify("my_secure_password", hashed_value)

Checking for Rehashing

You can check if a hash needs to be rehashed (e.g., if the hashing algorithm parameters are outdated):

needs_rehash = hash_manager.needs_rehash(hashed_value)

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests to help improve the project.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hash_forge-2.0.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hash_forge-2.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file hash_forge-2.0.tar.gz.

File metadata

  • Download URL: hash_forge-2.0.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for hash_forge-2.0.tar.gz
Algorithm Hash digest
SHA256 ae866afc1e9b6654dea2dc3be9535f721ee443474d4f42435963a6cc085cea95
MD5 7c7bc45a6725fd4889f0941d6135d47d
BLAKE2b-256 267f1edb1b47b04c5f176d1248cd88e0091470562cb603b496a47934b66c7049

See more details on using hashes here.

File details

Details for the file hash_forge-2.0-py3-none-any.whl.

File metadata

  • Download URL: hash_forge-2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for hash_forge-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09380e4b0293b7378b6ce2033f106dd0ae08142cbf906e3071a107bba8bf45dd
MD5 f7b9456bb53d27661df4e950d1675bbe
BLAKE2b-256 8900f4a8cd4c5a87cfef7b1e2f3991c6cf357b8de800e169ad59a96a5d65fdc4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page