recherche

Maison  >  Questions et réponses  >  le corps du texte

laravel - laravle5.0.22 Comment modifier la méthode de cryptage de vérification (passage à la vérification MD5)

La vérification de connexion auth n'utilise plus MD5. Comment ajouter une vérification MD5 sans modifier le code source. Veuillez donner une introduction détaillée.

PHP中文网PHP中文网2833 Il y a quelques jours728

répondre à tous(1)je répondrai

  • 天蓬老师

    天蓬老师2017-05-16 16:57:43

    La personne qui pose la question parle-t-elle de mots de passe cryptés ?

    Si c'est le cas, vous pouvez l'ajouter à User.phpUser.php加上这个

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

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

    修改部分:

    1. 在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;
        }
    
    }
    

    make your provider

    命令行:

    php artisan make:provider MD5HashServiceProvider

    在这个文件的register()方法写上:

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

    修改配置

    config/app.php

     Illuminate\Hashing\HashServiceProvider::class,

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

    Partie modifiée :

    1. Créez un dossier MD5/ sous app/. Créez une classe MD5Hasher (MD5Hasher.php) :

    MD5HashServiceProvider::class

    créez votre fournisseur

    Ligne de commande : rrreee

    Ecrivez dans la méthode register() de ce fichier : 🎜 rrreee

    Modifier la configuration

    🎜config/app.php, commentez la ligne suivante : 🎜 rrreee 🎜Ajoutez le vôtre : 🎜 rrreee 🎜🎜Joyeux hacking🎜🎜

    répondre
    0
  • Annulerrépondre