Laravel project login error: the MAC is invalid

After the laravel project is deployed to the server and the database is imported successfully

Background login error:

The reason is laravel’s app_Key and encrypt() functions( Encrypt() is a helper function of laravel, which is equivalent to the short form of crypt:: encrypt()

Once used   php artisan key:generate   App regenerated_Key, the MAC is invalid exception will be reported when decrypting the desrypt() function, which is due to app_The change of key leads to the change of MAC information, and the decrypt() decryption reports an exception

 

Solution:

Method 1. Re encrypt with encrypt() and log in again in the background. OK

Method 2. Encrypt () encryption is not conducive to project migration and deployment. Adopt the suggestions of this blog post and temporarily use hash encryption

 

Similar Posts: