How to Make Hash Password in Laravel?

Aug 08, 2022

.

Admin

How to Make Hash Password in Laravel?

Hello Friends,

In this tute, we will discuss How to Make Hash Password in Laravel. I explained simply step by step laravel generate password hash. I would like to show you how to make a hash password in laravel. you will learn how to get the hash password in laravel.

In this post, to save a password into db you need to encrypt it so, from a plain password you'll encrypt it using Hash::make('passwordstring'); and then save this hashed password in the database.

You can use this example with laravel 6, laravel 7, laravel 8 and laravel 9 version.

So, let's follow few step to create example of laravel hash password example.

Download Laravel


Let us begin the tutorial by installing a new laravel application. if you have already created the project, then skip following step.

composer create-project laravel/laravel example-app

Generate Hash Password in Controller File:

Example 1 :

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Hash;

class PostController extends Controller

{

/**

* Write Your Code..

*

* @return string

*/

public function store(Request $request)

{

$password = Hash::make('nikhilThumar');

dd($password);

}

}

Output:

"$2y$10$TqHFFq.0AnRXW8VupixQ/uVeeCuQ/HqnEGU2byBgKQtjh/sF62PAe"

Example 2 :

in this step we genarate uuid using toString() function

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PostController extends Controller

{

/**

* Write Your Code..

*

* @return string

*/

public function store(Request $request)

{

$password = bcrypt('nikhilThumar');

dd($password);

}

}

Output:

"$2y$10$pkA..onw7nRJaIePHbFbR.T9m6Y/AwkeroDplmYXuWh/d.zajVLrO"

now it works...

I hope it can help you...

#Laravel