Tuesday, June 28, 2016

How to generate Random Password in Laravel? | How to make Hashed Password in Laravel?


random password generator



In this tutorial we gonna talk about how can you generate a random password for the user. But we need to know why it's needed first.

Suppose there is a situation of sending password to the user for credential. So it's better to send him a hash::make password so other couldn't break it the middle. Besides if you save hashed password in database other's will not able to crack it. So, Let's begin how you can generate the secure hashed password in Laravel.

Laravel has a helper function called str_random() by which you can generate random string. And by this random string you can generate Hashed password.
$hashed_random_password = Hash::make(str_random(8));
and yes don't forget to use namespace otherwise it'll show namespace error:

use Illuminate\Support\Facades\Hash;
Generated password will be look like this:
And hashed password will be something like this:

That's it for today, hope the article will be helpful for you. Don't hesitate to ping me on comment if you find any difficulty.




Related Articles

0 comments:

Post a Comment