Hashing

Introduction

The Laravel Hash facade provides secure Bcrypt hashing for storing user passwords. If you are using the AuthController controller that is included with your Laravel application, it will be take care of verifying the Bcrypt password against the un-hashed version provided by the user.

Likewise, the user Registrar service that ships with Laravel makes the proper bcrypt function call to hash stored passwords.

Basic Usage

Hashing A Password Using Bcrypt

  1. $password = Hash::make('secret');

You may also use the bcrypt helper function:

  1. $password = bcrypt('secret');

Verifying A Password Against A Hash

  1. if (Hash::check('secret', $hashedPassword))
  2. {
  3. // The passwords match...
  4. }

Checking If A Password Needs To Be Rehashed

  1. if (Hash::needsRehash($hashed))
  2. {
  3. $hashed = Hash::make('secret');
  4. }