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.
SHA3_256Hasher and SHA3_512Hasher provide salted SHA-3 digests using Python’s stdlib hashlib. Both classes inherit from the internal SHA3Hasher base, which implements the Template Method pattern for hashing and verification. A random salt is generated at hash time and embedded in the output string, ensuring that two calls with the same input produce different hashes. No third-party packages are required.
Import
hashlib.
SHA3_256Hasher
Produces a 256-bit (32-byte) SHA-3 digest.
Constructor
Number of random bytes used to generate the salt. The salt is hex-encoded and embedded in the hash string alongside the digest.
Hash format
<salt> is a hex-encoded random byte sequence generated freshly on every hash() call.
Methods
hash(string: str) -> str
Generates a random salt, appends it to the input before hashing, and returns the hash in the canonical sha3_256$<salt>$<hex> format.
verify(string: str, hashed_string: str) -> bool
Parses the salt from hashed_string, re-derives the SHA3-256 digest using the same salt, and compares with hmac.compare_digest to prevent timing attacks.
needs_rehash(hashed_string: str) -> bool
Always returns False. SHA-3 hashers have no tunable cost parameters, so there is no configuration drift to detect.
SHA3_512Hasher
Produces a 512-bit (64-byte) SHA-3 digest. Identical in behaviour to SHA3_256Hasher but uses the SHA3-512 digest function.
Constructor
Number of random bytes used to generate the salt. The salt is hex-encoded and embedded in the hash string.
Hash format
Methods
hash(string: str) -> str
Generates a random salt and returns the SHA3-512 hash in sha3_512$<salt>$<hex> format.
verify(string: str, hashed_string: str) -> bool
Re-derives the SHA3-512 digest using the stored salt and compares the result in constant time.
needs_rehash(hashed_string: str) -> bool
Always returns False.
Base class
Both hashers subclass the internalSHA3Hasher base class, which uses the Template Method pattern. SHA3Hasher implements hash, verify, and needs_rehash in terms of four abstract hooks — _do_hash, _parse_hash, _do_verify, and _check_needs_rehash — that concrete subclasses fill in by setting algorithm and _digest_name class variables. You do not need to interact with SHA3Hasher directly.
