Skip to main content

Overview

The Hash 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 call Hash::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 the Illuminate\Contracts\Hashing\Hasher interface. HashManager’s make(), check(), and related methods forward the call to the current driver returned by driver().
The built-in 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 the boot() method of AppServiceProvider with Hash::extend().
The closure receives the container instance. 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.
HASH_PEPPER is a secret. Keep it in .env and do not commit it to version control. Changing or losing the pepper makes all existing passwords unverifiable.

Verifying the behavior

After you register the driver, existing Hash 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

Switching HASH_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.
Last modified on November 23, 2026