how to generate random passwords in laravel

100 0 0 0

Last Updated : 2021-12-03 01:57:03

this snippet will teach you how to generate random passwords in laravel through laravel helper functions

you can create random password through laravel helper function like this

$random_password = Str::random(40);
//$random_password = Str::random(lengthofpassword);

Don't forget to use str like this

use Illuminate\Support\Str;

use hash to create hashed password from generated random password like this

$hashed_password = Hash::make(str::random(40)); 
$hashed_password = Hash::make($random_password);

Don't forget to use hash like this

use Illuminate\Support\Facades\Hash;

Mahmoud Anwar

Mahmoud Anwar

Back End Developer with a passion for developing innovative web applications that expedite the efficiency and effectiveness of organizational success. Well-versed in technology and writing code to create systems that are reliable and user-friendly. Also has the proven ability to motivate, educate, and collaborate effectively to build web applications and effectively track changes. Confident communicator, strategic thinker, and innovative creator to develop software that is customized to meet a company’s organizational needs, highlight their core competencies, and further their success.