When you need to hash and check passwords using an algorithm other than supported bcrypt
or argon
there is an easy way to add a custom one. When I needed to use md5
for a legacy project I have tried to quickly google a solution and most I had found were based on creating a ServiceProvider
which completely overrides builtin HashManager
. The other way would be to extend it instead.
So I have added a following into my AuthServiceProvider
's boot()
method:
$this->app->make('hash')->extend('md5', function() {
return new Md5Hasher;
});