贵州网站建设,表白网站在线制作软件,erp系统要学多久,芗城区建设局网站首先声明#xff1a;这里只是作为一个记录#xff0c;实行拿来主义#xff0c;懒得去记录那些分析源码的过程#xff0c;不喜勿喷#xff0c;可直接划走。 第一步#xff1a;创建文件夹#xff1a;app/Helpers/Hasher; 第二步#xff1a;创建文件#xff1a; app/Help…首先声明这里只是作为一个记录实行拿来主义懒得去记录那些分析源码的过程不喜勿喷可直接划走。 第一步创建文件夹app/Helpers/Hasher; 第二步创建文件 app/Helpers/Hasher/MD5Hash.php; app/Providers/MD5HashServiceProvider.php 第三步修改文件 1.MD5Hash.php:
namespace App\Helpers\Hasher;use Illuminate\Contracts\Hashing\Hasher;class MD5Hash implements Hasher
{public function check($value, $hashedValue, array $options []){return $this-make($value.$hashedValue[salt]) $hashedValue[password];}public function needsRehash($hashedValue, array $options []){return false;}public function make($value, array $options []){return md5($value);}/*** param string $hashedValue* return array*/public function info($hashedValue){// TODO: Implement info() method.}
}说明check方法中的$hashvalue主要是根据自己的App/User.php中的getAuthPassword方法返回的内容。构造加密算法的主要是在make方法中实现。 2.MD5HashServiceProvider.php:
?phpnamespace App\Providers;use Illuminate\Support\ServiceProvider;
use App\Helpers\Hasher\MD5Hash;class MD5HashServiceProvider extends ServiceProvider
{/*** Register services.** return void*/public function register(){//}/*** Bootstrap services.** return void*/public function boot(){//$this-app-singleton(hash, function () {return new MD5Hash;});}public function provides(){
// return parent::provides(); // TODO: Change the autogenerated stub
// return [hash];}
}说明这个文件照搬就可以 3.app/User.php:
?phpnamespace App;use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;class User extends Authenticatable
{use Notifiable;/*** The attributes that are mass assignable.** var array*/protected $fillable [username, email, password,];/*** The attributes that should be hidden for arrays.** var array*/protected $hidden [password, remember_token,];/*** The attributes that should be cast to native types.** var array*/protected $casts [email_verified_at datetime,];protected $table rk_admin;public function getAuthPassword(){return [password$this-attributes[password], salt$this-attributes[salt]];}}
说明:这里的getAuthPassword方法是返回需要的字段。需要添加自己的admin表。 4.config/app.php
// Illuminate\Hashing\HashServiceProvider::class, //修改为自己的md5\App\Providers\MD5HashServiceProvider::class, //这里修改为自己的服务提供者同理其他类型的加密算法可以在md5hash.php中自己去自由发挥。