Hashing

Introduction

The Lumen Hash facade provides secure Bcrypt hashing for storing user passwords.

Basic Usage

Note: If you intend to use the Hash facade, be sure to uncomment the $app->withFacades() call in your bootstrap/app.php file.

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. // The passwords match...
  3. }

Checking If A Password Needs To Be Rehashed

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