Hello,
Aug 24, 2017 Running php artisan key:generate in a Laravel project where the.env file does not contain an APPKEY= line results in the following output: Application key base64:KEYHERE= set successfully. However, the key is not written to the.env file, so the status message is incorrect. Steps To Reproduce: Create a.env file without an APPKEY= line. Laravel Advent Calendar 2017 22日目の記事です。. Laravelerにおなじみ?、最初にやらされる php artisan key:generate 。 それで.env に APPKEY=base64:xxxxxxx が埋まりますよね。 自分はLaravel5くらいから使っているんですが、あれって具体的に何に使われているんだろうと思って、今回調べてみました!.
Having a hard time with this.My app was working fine, today I restarted the laptop and receive this error:
´´´RuntimeExceptionNo application encryption key has been specified.´´´
I have set my key and even regenerated one using the command
´´´APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=´´´
I ran all these commandsphp artisan cache:clearphp artisan view:clearphp artisan config:clearphp artisan config:cache
I have also set the key in the app.php
I really tried everything, even restarted apache and checked if the mod_rewritte was enabled, all good.I have also redownloaded a new .env file to make sure it was not a problem with the file itself.
Any other ideas please?
- Laravel Tutorial
Laravel Generate App Encryption Key Download
- Laravel Useful Resources
- Selected Reading
Encryption is a process of converting a plain text to a message using some algorithms such that any third user cannot read the information. This is helpful for transmitting sensitive information because there are fewer chances for an intruder to target the information transferred.
Encryption is performed using a process called Cryptography. The text which is to be encrypted is termed as Plain Text and the text or the message obtained after the encryption is called Cipher Text. The process of converting cipher text to plain text is called Decryption.
Laravel uses AES-256 and AES-128 encrypter, which uses Open SSL for encryption. All the values included in Laravel are signed using the protocol Message Authentication Code so that the underlying value cannot be tampered with once it is encrypted.
Configuration
The command used to generate the key in Laravel is shown below −
Please note that this command uses the PHP secure random bytes’ generator and you can see the output as shown in the screenshot given below −
Laravel New App
The command given above helps in generating the key which can be used in web application. Observe the screenshot shown below −
Note
The values for encryption are properly aligned in the config/app.php file, which includes two parameters for encryption namely key and cipher. If the value using this key is not properly aligned, all the values encrypted in Laravel will be insecure.
Encryption Process
Encryption of a value can be done by using the encrypt helper in the controllers of Laravel class. These values are encrypted using OpenSSL and AES-256 cipher. All the encrypted values are signed with Message Authentication code (MAC) to check for any modifications of the encrypted string.
The code shown below is mentioned in a controller and is used to store a secret or a sensitive message.
Decryption Process
Decryption of the values is done with the decrypt helper. Observe the following lines of code −
Please note that if the process of decryption is not successful because of invalid MAC being used, then an appropriate exception is thrown.