laravel 不更新 env 文件的 AES 密钥生成

laravel AES key generation without updating env file

我正在使用 php artisan key:generate 生成 AES 密钥,但它每次都会更新 env 文件。

我需要为聊天室生成一个唯一的 AES 密钥

如有任何建议,我们将不胜感激。

这不会更新环境文件:

php artisan key:generate --show

如果您查看 the source of this command,您可以找到用于生成此密钥的函数。如果您想将此密钥用于其他用途,您可以重复使用此功能。

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