Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel AES key generation without updating env file

Tags:

php

laravel

aes

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.

like image 554
Rp9 Avatar asked Oct 15 '25 22:10

Rp9


1 Answers

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'])
    );
}
like image 78
Jerodev Avatar answered Oct 17 '25 12:10

Jerodev