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.
HashForgeConfig is a dataclass that centralises every tunable parameter for Hash Forge’s supported algorithms in one object. Instead of scattering rounds=14 or iterations=200_000 keyword arguments across your codebase, you define all parameters once — from environment variables in production, a JSON file during integration testing, or a plain dict in unit tests — and pass the config object to HashManager.from_config() at startup.
Loading Configuration
From environment variables
HashForgeConfig.from_env() reads all recognised HASH_FORGE_* environment variables and falls back to library defaults for any that are not set.
prefix parameter defaults to "HASH_FORGE_" but can be customised:
From a JSON file
HashForgeConfig.from_json() reads a JSON file and maps its keys directly to dataclass fields.
From a Python dict
HashForgeConfig.from_dict() accepts any plain dictionary. Keys map directly to dataclass fields; unrecognised keys raise a TypeError.
Environment Variable Reference
| Variable | Default | Description |
|---|---|---|
HASH_FORGE_PBKDF2_ITERATIONS | 150000 | PBKDF2 iteration count |
HASH_FORGE_PBKDF2_SALT_LENGTH | 16 | Salt length in bytes |
HASH_FORGE_BCRYPT_ROUNDS | 12 | BCrypt cost factor |
HASH_FORGE_ARGON2_TIME_COST | 3 | Argon2 time cost |
HASH_FORGE_ARGON2_MEMORY_COST | 65536 | Argon2 memory (KiB) |
HASH_FORGE_ARGON2_PARALLELISM | 1 | Argon2 parallelism |
HASH_FORGE_ARGON2_HASH_LEN | 32 | Argon2 output length |
HASH_FORGE_SCRYPT_N | 32768 | Scrypt CPU/memory cost |
HASH_FORGE_SCRYPT_R | 8 | Scrypt block size |
HASH_FORGE_SCRYPT_P | 1 | Scrypt parallelism |
Using Config with HashManager
Pass the config object and the algorithm names you want toHashManager.from_config(). The method reads the relevant fields from the config and passes them to each hasher’s constructor.
from_algorithms: the first algorithm becomes the preferred hasher for new hashes.
Complete startup example
Exporting Configuration
to_dict()
config.to_dict() returns a plain dictionary containing every configuration field. Use it to inspect the current state of a config object, pass settings to another system, or serialise to a format other than JSON.
to_json(path)
config.to_json() serialises the current configuration to a JSON file. Use this to capture a working configuration snapshot or to pre-generate config files for deployment.
HashForgeConfig.from_json("hashforge.json").
get_hasher_config(algorithm)
config.get_hasher_config() returns a dictionary of constructor keyword arguments for the named algorithm. This is the same extraction that HashManager.from_config() performs internally, but you can call it directly when you need per-algorithm settings without creating a manager.
Security Minimums
Hash Forge enforces minimum values for every security-sensitive parameter. Setting any value below its minimum raisesInvalidHasherError when the hasher is instantiated.
| Parameter | Minimum |
|---|---|
| PBKDF2 iterations | 150,000 |
| BCrypt rounds | 12 |
| Argon2 time_cost | 2 |
| Argon2 memory_cost | 32,768 KiB |
| Scrypt N | 16,384 |
| Scrypt r | 8 |
| Scrypt p | 1 |
