laravel - laravle5.0.22 How to modify the verification encryption method (change to MD5 verification)
PHP中文网
PHP中文网 2017-05-16 16:55:43
0
1
548

auth Login verification no longer uses MD5. How to add an MD5 verification without modifying the source code. Please give a detailed introduction.

PHP中文网
PHP中文网

认证0级讲师

reply all (1)
Peter_Zhu

Is the questioner talking about encrypted passwords?

If yes, you can add thisUser.phpin

public function setPasswordAttribute($password) { $this->attributes['password'] = md5($password); }

==================================================== ==============

Modified part:

1. Inapp/下创建一个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; } }

make your provider

Command line:

php artisan make:provider MD5HashServiceProvider

Write in theregister()method of this file:

public function register() { $this->app['hash'] = $this->app->share(function () { return new MD5Hasher(); }); }

Modify configuration

config/app.php, comment the following line:

Illuminate\Hashing\HashServiceProvider::class,

Add yours:

MD5HashServiceProvider::class

Happy Hacking

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!