Overview
TheHash facade proxies to Illuminate\Hashing\HashManager. HashManager extends Illuminate\Support\Manager, and ships with three drivers by default: bcrypt, argon, and argon2id.
The official documentation only covers switching drivers with HASH_DRIVER, but because HashManager uses the same mechanism as Manager, you can add your own hash drivers. This guide implements a driver that mixes a server-side secret (a pepper) into the password before storing it with bcrypt.
How a built-in driver is resolved
When you callHash::make(), Manager::driver() first resolves the actual driver instance.
createDriver() first looks for a registered custom creator. If none exists, it looks for a create{Name}Driver() method.
HashManager has createBcryptDriver(), createArgonDriver(), and createArgon2idDriver(), which return the matching hasher. If you register a driver under one of these names with extend(), the custom creator takes precedence.
The driver contract
A hash driver implements theIlluminate\Contracts\Hashing\Hasher interface. HashManager’s make(), check(), and related methods forward the call to the current driver returned by driver().
BcryptHasher extends AbstractHasher, which provides the shared info() and check() logic. If your driver extends the same base class, it inherits the handling of empty hashes in check().
Implementing a pepper hasher
Instead of passing the password directly to bcrypt, this driver applies HMAC-SHA256 with a secret key first and then passes the result to bcrypt. bcrypt only uses the first 72 bytes of its input, so the HMAC step turns any password into a fixed-length value before hashing.check() calls password_verify() directly because AbstractHasher::check() would verify the plain value without the pepper. The override applies the pepper before verification.
Registering the driver
Register the custom driver in theboot() method of AppServiceProvider with Hash::extend().
extend() binds the closure to HashManager, so $this inside the closure refers to the HashManager instance.
Store the pepper in your .env file. Changing the pepper makes all existing hashes unverifiable, so decide on it once and keep it stable.
Verifying the behavior
After you register the driver, existingHash facade calls work without changes.
Hash::driver() calls HashManager::driver() and returns the driver with the given name. Hash::make() uses the default driver, so setting HASH_DRIVER=pepper makes it use the pepper driver.
Impact on existing hashes
SwitchingHASH_DRIVER or changing the pepper makes existing hashes fail check(). Do not change the pepper once it is set. If your application already has users, plan how to migrate their hashes before you switch drivers.
Summary
Next steps
Custom Authentication Guard
Learn how authentication uses
Hash::check() from the guard side.Hashing
Review the standard bcrypt and Argon2 usage and configuration.