Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

arif's avatar
Level 1

The MAC is invalid.

DecryptException in BaseEncrypter.php line 48:
The MAC is invalid.
i got this error when i m using Crypt::encrypt and Crypt::decrypt i dont know why it is coming and my URL gets lengthy so can any one tell me the solutions or the reason behind this... thanks :)
0 likes
5 replies
InspiredPrynce's avatar

The problem is you generated a new APP_KEY, then if you try to decrypt the old encrypted data it will show the DecryptException: The MAC is invalid.

If you want to decrypt the old data you need to restore your old APP_KEY.

After realizing that, now, adding a new problem there, if you stored new data with another APP_KEY or another encryption method you have a problem on the data because they are mixed on the table.

In case you don't know when do you started with the new encrypt method or differentiate the new encrypted entries, the fastest solution would be reset all the passwords with the new encrypt method.

You can learn more about how Laravel encryption works on the official Laravel docs.

Copy the APP_KEY from the environment it was working dev to the production and the issue was solved. you may want to try it.

florenxe's avatar

In my case, I needed to pass the encrypted data from one laravel application to another. The fix was to ensure both app used the same APP_KEY

1 like

Please or to participate in this conversation.