John Davidson

php - In which file does laravel decrypt the hashed password with the user provided password using the laravel/ui package?

0 comments
Message:


I have to implement the logic where I don't want to decrypt or encrypt the password of laravel/UI default package. I have trouble finding where laravel encrypt or decrypts the password. Which files I have to change to make the settings on my way.



My Answer:
In Laravel, the hashing and verification of passwords is handled by the `Hash` facade, which uses the `bcrypt` algorithm by default. The actual encryption and decryption of passwords is not done directly in the Laravel UI package, but rather in the core Laravel framework.

If you want to customize the password hashing logic in Laravel, you can do so by modifying the `config/hashing.php` configuration file. In this file, you can specify the hashing algorithm and options that Laravel should use when hashing passwords.

To implement your own custom logic for password hashing and verification, you can create a custom service provider and bind your own implementation of the `Illuminate\Contracts\Hashing\Hasher` interface to the `Hash` facade.

Here is an example of how you can create a custom hasher and bind it to the `Hash` facade in a service provider:

php
use Illuminate\Support\ServiceProvider;
use App\Services\CustomHasher;

class CustomHasherServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton('hash', function () {
return new CustomHasher();
});
}
}


You can then register your custom service provider in the `config/app.php` configuration file:

php
'providers' => [
// Other service providers...
App\Providers\CustomHasherServiceProvider::class,
],


With this setup, Laravel will use your custom hasher implementation for hashing and verifying passwords instead of the default `bcrypt` algorithm. You can then implement your own logic for password hashing and verification in the `CustomHasher` class.

Rate this post

3 of 5 based on 4676 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us