Reputation: 367
Laravel's default UserFactory class contains following definition method:
public function definition()
{
return [
'name' => $this->faker->name(),
'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
The password key contains hashed password string value. In case I want to use another password value, what hashing function should I use to hash it like this:
'password' => HashFunctionName('mynewpassword');
? For context: I use Auth:attempt function for authentication:
public function login(LoginRequest $request){
if (Auth::attempt($request->only('email', 'password'))){
$request->session()->regenerate();
return response('you are logged in');
}
return response('Credentials are not valid', 401);
}
Upvotes: 1
Views: 923
Reputation: 7628
By default, Bcrypt will be used as the hashing algorithm:
https://laravel.com/docs/8.x/hashing#introduction
The code uses Illuminate\Support\Facades\Hash::make($somePassword);
which will create a Bcrypt hash for your given password, according to the settings you have defined in config/hashing.php
.
Upvotes: 2