yadhul's avatar

The MAC is invalid. error when i open my website

iam getting an error mac is invalid when i open my site..

DecryptException in E:\xampp\htdocs\stagingnew\local\vendor\laravel\framework\src\Illuminate\Encryption\BaseEncrypter.php line 49: The MAC is invalid.

error like this

0 likes
8 replies
yadhul's avatar

acutaly clearing cache and clearing cookie of browser make my prblm clear.... now no error.... @bobbybouwmann

2 likes
vrajroham's avatar

app key matters in encryption and decryption. I was having 2 sub domains with different projects in which I was encrypting value on sub domain and 1 and trying to decrypt on sub domain 2. Issue was resolved when both projects were having same appkey. Note: No projects should have same appkey!!!

2 likes
Karthick-dev17's avatar

@vrajroham yeah you correct i used same app key in my both projects but still got this error
The MAC is invalid.

stuartcusack's avatar

I am also getting "The MAC is invalid - DecryptException in BaseEncrypter.php line 48". I have cleared artisan cache, composer cache, dumped the autoload, emptied the browser cache and still nothing.

Decryption is working on my production server and also on my other PC, but not on my laptop. All files are the same, the database is the same and the APP_KEY is the same in the .env file.

I am using MCRYPT_RIJNDAEL_128 as the cipher in my config/app.php file

This is weird, but if I hard-code the 'key' in config/app.php then everything works, but if I let it load the key using env('APP_KEY') then the error appears again.

The .env file is definitely being loaded and so is the APP_KEY. I can verify this using dd(env('APP_KEY')) in my routes file.

Chris1904's avatar

I am having the same issue, now that I am trying to clone my project from Github to my production server using the exact same variables.

Going through these steps

composer dump-autoload

composer clear-cache

php artisan cache:clear

php artisan view:clear

I get [Illuminate\Contracts\Encryption\DecryptException] The MAC is invalid. when I try to cache:clear.

Any tips?

1 like

Please or to participate in this conversation.