mcrypt_decrypt(): Key of size 15 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported
How Can I fix this issue? my key is set - can not change it. It has to be a local change, I think my local PHP version is too advanced for the project I loaded. How can I fix this?
I went ahead and created a function based on Hanky 웃 Panky's answer.
This can be used with any key length to make sure it's the correct size.
For Laravel 5
Just run
php artisan key:generate
:If you don't see your key updated, just paste it in your
.env
file.APP_KEY=EaaJgaD0uFDEg7tpvMOqKfAQ46Bqi8Va
Refresh your page
You don't need to pad the key with "\0".
I had the same issue when migrating to a new PHP 7 server and I got the message :
The key I had in the code was a string of 19 characters, I simply changed it to a string of 32 characters and everything was fine again.
So as the error message suggests, use a valid size key.
If your encryption code looks like this:
You will want to change the $key to a 128 or 256 bit encrypted code. I simply copied a code that I generated from here: Generate Code
I created a 256 bit code for mine which consists of 32 characters and thus fixes the issue of the invalid key size of 15 or whatever number is causing the error. So whatever is set for $key you need to change that to a valid code and then it should work fine.
Did you update to 5.6? It says
Reference
Read the last line of that quote, and there you will find your solution :)
That means you need to pad your key with
\0
(that's what previous versions were doing for you)I had the same problem, but fixed it with this