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.
AsyncHashMixin is a mixin class that HashManager inherits from, giving every HashManager instance a full suite of async hashing methods. Because password hashing algorithms like Argon2, bcrypt, and PBKDF2 are intentionally CPU-intensive, running them directly in an async event loop would block other coroutines. AsyncHashMixin solves this by offloading each synchronous operation to Python’s default thread-pool executor via asyncio.get_running_loop().run_in_executor(None, ...), keeping the event loop free.
You do not import or instantiate
AsyncHashMixin directly. All HashManager instances already have these methods available — simply await them from any async context.Methods
hash_async
preferred_hasher by running the synchronous hash() method in a thread-pool executor.
The plaintext string to hash.
str — the hashed string, identical to what hash() would produce.
verify_async
verify() method in a thread-pool executor. Algorithm routing behaves identically to the synchronous version.
The plaintext string to verify.
The stored hash to compare against.
bool — True if the string matches the hash, False otherwise.
needs_rehash_async
needs_rehash() method in a thread-pool executor.
The stored hash to evaluate.
bool — True if the hash should be regenerated.
hash_many_async
hash_async calls as tasks and awaiting them together with asyncio.gather. The output list preserves the same order as the input list.
A list of plaintext strings to hash.
list[str] — hashed strings in the same order as the input.
verify_many_async
asyncio.gather. Each pair is verified independently and the results are returned in the same order as the input.
A list of
(plaintext, hashed_string) tuples to verify.list[bool] — verification results in the same order as the input.
Concurrency Model
All five methods delegate toasyncio.get_running_loop().run_in_executor(None, ...), which submits work to Python’s default ThreadPoolExecutor. This means:
- The event loop is never blocked — other coroutines continue to run while hashing is in progress.
- Hashing work is distributed across OS threads, providing true concurrency for I/O-bound async applications.
- The default executor uses
min(32, os.cpu_count() + 4)threads (Python 3.8+). For workloads with very high parallelism, supply a custom executor to the event loop vialoop.set_default_executor.
