Rp9
Rp9

Reputation: 1963

laravel AES key generation without updating env file

I am using php artisan key:generate for generating AES key,but it updating env file each time.

I need to generate a unique AES key for a chatroom.

Any suggestion will be appreciated.

Upvotes: 4

Views: 326

Answers (2)

Jerodev
Jerodev

Reputation: 33196

If you take a look at the source of this command, you can find the function that is used to generate this key. If you want to use this key for something else, you can reuse this function.

protected function generateRandomKey()
{
    return 'base64:'.base64_encode(
        Encrypter::generateKey($this->laravel['config']['app.cipher'])
    );
}

Upvotes: 2

Sameer Shaikh
Sameer Shaikh

Reputation: 7824

This will not update the env file:

php artisan key:generate --show

Upvotes: 2

Related Questions