Documentation Index
Fetch the complete documentation index at: https://kawax.biz/llms.txt
Use this file to discover all available pages before exploring further.
What is hashing
Hashing converts plain-text data such as passwords into a fixed-length string through a one-way transformation. The same input always produces the same hash, but you cannot recover the original plain text from a hash. Laravel’sHash facade supports bcrypt and Argon2 hashing algorithms for secure password storage.
Algorithm comparison
| Algorithm | Characteristics | Recommended use |
|---|---|---|
| bcrypt | Work factor (rounds) controls computation cost. Default driver | General web applications |
| argon2i | Configurable memory, time, and threads. Resistant to side-channel attacks | High-security scenarios |
| argon2id | Hybrid of argon2i and argon2d. Recommended by the PHC | New projects using Argon2 |
The bcrypt “work factor” controls how long it takes to generate a hash. A slower hash increases resistance to brute-force attacks. As hardware becomes faster, you can raise the work factor to maintain security.
Hashing and verification flow
Configuration
By default, Laravel uses thebcrypt driver. You can change it with the HASH_DRIVER environment variable.
config:publish.
config/hashing.php to adjust default work factors and other settings.
Basic usage
Hashing a password
Pass a plain-text password toHash::make() to get a hash. Store this hash value in your database.
Adjusting the bcrypt work factor
Use therounds option to control the computation cost of hash generation. Higher values are more secure but slower.
The default value of 12 is appropriate for most applications.
Adjusting the Argon2 work factor
When using Argon2, adjust the computation cost with thememory, time, and threads options.
| Option | Description | Default |
|---|---|---|
memory | Memory to use (KiB) | 65536 |
time | Number of iterations | 4 |
threads | Number of threads | 1 |
Verifying a password
UseHash::check() to verify that a plain-text password matches a stored hash.
This is typically used inside login logic.
Auth::attempt(), this comparison happens automatically. You call Hash::check() directly when you need to manually verify a password, such as confirming the current password before a change.
Determining if a password needs rehashing
Hash::needsRehash() checks whether the work factor used to hash a password differs from the current configuration.
Use this to update existing hashes when you raise the work factor.
Hash algorithm verification
By default,Hash::check() verifies that the given hash was generated using the application’s configured algorithm.
If the algorithms differ, a RuntimeException is thrown.
This protects against hash algorithm manipulation attacks.
If you need to support multiple algorithms simultaneously — for example, during a migration from one algorithm to another — you can disable this verification by setting HASH_VERIFY to false.
Summary
| Goal | How |
|---|---|
| Hash a password | Hash::make($password) |
| Verify a hash | Hash::check($plain, $hash) |
| Check if rehashing is needed | Hash::needsRehash($hash) |
| Change the hashing driver | HASH_DRIVER environment variable |
| Disable algorithm verification | HASH_VERIFY=false |
Next steps
Authentication
Learn how login flows use
Hash::check() and how Laravel’s authentication system works end to end.