Home  >  Article  >  Backend Development  >  Detailed explanation of the solution to the project login error in the Laravel framework: The MAC is invalid.

Detailed explanation of the solution to the project login error in the Laravel framework: The MAC is invalid.

黄舟
黄舟Original
2017-09-11 09:34:022123browse

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

Backend login error:

The reason is Laravel's APP_KEY and encrypt() functions Encryption issue. (encrypt() is Laravel's helper function, which is equivalent to the abbreviation of Crypt::encrypt())

Once it is regenerated with php artisan key:generate APP_KEY, when the decrypt() function decrypts, the MAC is invalid exception will be reported. This is because the APP_KEY change causes the MAC information to change, and the decrypt() function will report an exception.

Solution:

Method 1. Use encrypt() to encrypt again, log in again in the background, OK.

Method 2. encrypt() encryption is not conducive to project transplantation and deployment. Adopt the suggestion of this blog post and temporarily use hash encryption.

The above is the detailed content of Detailed explanation of the solution to the project login error in the Laravel framework: The MAC is invalid.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn