TECHIES WORLD

For Techs.... Techniques.... Technologies....

ApacheCpanelLinuxPHP

Laravel Mcrypt Warning: mcrypt_decrypt(): Key of size 21 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in

Warning: mcrypt_decrypt(): Key of size 21 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in

The error is because of the Laravel APP_KEY is not using one of the supported character lengths. From Php version 5.6 onward, its enforcing proper key sizes for mcrypt.

This can be fixed by padding the APP_KEY with '\0' bytes to the next valid size (16, 24, 32 characters).

If it is 10 characters, pad it to 16.
If it is 20 characters, pad it to 24.
If it is 25 characters, pad it to 32.

Laravel APP_KEY should be specified in one of the below locations.

config/app.php
.env

For config/app.php, open the file pad the current key with required '\0' bytes to the next valid size.

'key' => env('APP_KEY', "12345\0\0\0\0\0\0\0\0\0\0\0"),

For .env, open the file pad the current key with required '\0' bytes to the next valid size.

APP_KEY="12345\0\0\0\0\0\0\0\0\0\0\0"

That's all…

Leave a Reply