Hashing
The Laravel facade provides secure Bcrypt and Argon2 hashing for storing user passwords. If you are using the built-in LoginController
and RegisterController
classes that are included with your Laravel application, they will use Bcrypt for registration and authentication by default.
You may hash a password by calling the make
method on the facade:
Adjusting The Bcrypt Work Factor
Adjusting The Argon2 Work Factor
If you are using the Argon2 algorithm, the make
method allows you to manage the work factor of the algorithm using the memory
, , and threads
options; however, the defaults are acceptable for most applications:
Verifying A Password Against A Hash
The check
method allows you to verify that a given plain-text string corresponds to a given hash. However, if you are using the LoginController
included with Laravel, you will probably not need to use this directly, as this controller automatically calls this method: