auth Login verification no longer uses MD5. How to add an MD5 verification without modifying the source code. Please give a detailed introduction.
天蓬老师2017-05-16 16:57:43
Is the questioner talking about encrypted passwords?
If yes, you can add this User.php
in
public function setPasswordAttribute($password)
{
$this->attributes['password'] = md5($password);
}
==================================================== ==============
Modified part:
app/
下创建一个MD5/
文件夹。里面创建一个MD5Hasher类(MD5Hasher.php)
: class MD5Hasher implements Illuminate/Contracts/Hashing/Hasher {
/**
* Hash the given value.
*
* @param string $value
* @return array $options
* @return string
*/
public function make($value, array $options = []) {
return md5($value);
}
/**
* Check the given plain value against a hash.
*
* @param string $value
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function check($value, $hashedValue, array $options = []) {
return $this->make($value) === $hashedValue;
}
/**
* Check if the given hash has been hashed using the given options.
*
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function needsRehash($hashedValue, array $options = []) {
return false;
}
}
Command line:
php artisan make:provider MD5HashServiceProvider
Write in the register()
method of this file:
public function register()
{
$this->app['hash'] = $this->app->share(function () {
return new MD5Hasher();
});
}
config/app.php
, comment the following line:
Illuminate\Hashing\HashServiceProvider::class,
Add yours:
MD5HashServiceProvider::class
Happy Hacking