Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Zozi96/hash-forge/llms.txt

Use this file to discover all available pages before exploring further.

Ripemd160Hasher and WhirlpoolHasher are legacy digest hashers that rely on the pycryptodome library. Ripemd160Hasher is suitable for verifying RIPEMD-160 hashes from older systems, while WhirlpoolHasher is fully deprecated — its implementation uses SHA-512 internally rather than the Whirlpool algorithm, and it blocks the creation of new hashes unless explicitly opted in. Both hashers are provided to support migration scenarios and should not be used for new hash generation.

Installation

Both hashers require the pycryptodome package:
pip install "hash-forge[crypto]"

Ripemd160Hasher

A hasher backed by pycryptodome’s Crypto.Hash.RIPEMD160. Accepts both the canonical ripemd160 prefix and the legacy RIPEMD-160 prefix produced by older tools.
algorithm = 'ripemd160'
legacy_algorithm = 'RIPEMD-160'

Import

from hash_forge.hashers import Ripemd160Hasher

Constructor

Ripemd160Hasher()
No configuration parameters. The hasher loads Crypto.Hash.RIPEMD160 on instantiation.

Hash format

ripemd160$<hex_digest>

Methods

hash(string: str) -> str

Computes the RIPEMD-160 digest of string and returns it in ripemd160$<hex> format.

verify(string: str, hashed_string: str) -> bool

Parses the algorithm prefix and hex digest from hashed_string, re-computes the RIPEMD-160 digest of string, and compares using hmac.compare_digest. Accepts both ripemd160$ and RIPEMD-160$ prefixes.

needs_rehash(hashed_string: str) -> bool

Returns True when the prefix in hashed_string is the legacy RIPEMD-160 token rather than the canonical ripemd160 token. This allows applications to normalise old hashes to the canonical format during a migration.

can_handle(hashed_string: str) -> bool

Returns True if hashed_string starts with either ripemd160$ or RIPEMD-160$.

WhirlpoolHasher

WhirlpoolHasher is deprecated. Despite the name, its internal implementation uses SHA-512 (via Crypto.Hash.SHA512) rather than the Whirlpool algorithm. New hashes are blocked by default — calling hash() raises InvalidHasherError unless allow_legacy_hashing=True is passed. Instantiation always emits a DeprecationWarning. Use this hasher only to verify or migrate existing Whirlpool-labelled hashes produced by an older version of Hash Forge.
algorithm = 'whirlpool'

Import

from hash_forge.hashers import WhirlpoolHasher

Constructor

WhirlpoolHasher(allow_legacy_verify: bool = True, allow_legacy_hashing: bool = False)
allow_legacy_verify
bool
default:"true"
When True (the default), the verify method will attempt to verify existing whirlpool$ hashes. Set to False only if you want to completely disable verification.
allow_legacy_hashing
bool
default:"false"
When False (the default), calling hash() raises InvalidHasherError. Set to True only if you explicitly need to produce new SHA-512-backed whirlpool$ hashes for backward-compatibility purposes.
If both allow_legacy_verify=False and allow_legacy_hashing=False are passed simultaneously, the constructor itself raises InvalidHasherError because there is no valid use for a WhirlpoolHasher that can neither hash nor verify. A DeprecationWarning is always emitted at instantiation time, regardless of the flags.

Hash format

whirlpool$<sha512_hex_digest>
The hash stored under this format is a SHA-512 digest, not a Whirlpool digest.

Methods

hash(string: str) -> str

Raises InvalidHasherError unless allow_legacy_hashing=True. When permitted, computes a SHA-512 digest of string and returns it in whirlpool$<hex> format.

verify(string: str, hashed_string: str) -> bool

Returns False immediately when allow_legacy_verify=False. Otherwise parses the prefix and hex digest from hashed_string, re-computes the SHA-512 digest, and compares using hmac.compare_digest.

needs_rehash(hashed_string: str) -> bool

Returns True when the algorithm prefix in hashed_string does not match whirlpool.

Code example

from hash_forge.hashers import Ripemd160Hasher

# Canonical hashing and verification
hasher = Ripemd160Hasher()
hashed = hasher.hash("legacy_data")
assert hasher.verify("legacy_data", hashed)

# Legacy prefix normalisation
legacy_hash = "RIPEMD-160$" + hashed.split("$", 1)[1]
assert hasher.can_handle(legacy_hash)
assert hasher.needs_rehash(legacy_hash) == True   # non-canonical prefix
assert hasher.needs_rehash(hashed) == False        # already canonical
import warnings
from hash_forge.hashers import WhirlpoolHasher

# Verify existing whirlpool hashes during migration only
with warnings.catch_warnings():
    warnings.simplefilter("ignore", DeprecationWarning)
    verifier = WhirlpoolHasher(allow_legacy_verify=True, allow_legacy_hashing=False)

old_hash = "whirlpool$<hex_from_old_system>"
result = verifier.verify("original_value", old_hash)

Build docs developers (and LLMs) love