generateRandomSalt(); if ($this->option('show')) { return $this->line(''.$salt.''); } // Next, we will replace the application salt in the environment file so it is // automatically setup for this developer. This salt gets generated using a // secure random byte generator and is later base64 encoded for storage. $this->setKeyInEnvironmentFile($salt); $this->laravel['config']['secure.salt'] = $salt; $this->info("Application salt [$salt] set successfully."); } /** * Set the application salt in the environment file. * * @param string $salt * @return void */ protected function setKeyInEnvironmentFile($salt) { file_put_contents($this->laravel->environmentFilePath(), str_replace( 'SALT = '.$this->laravel['config']['secure.salt'], 'SALT = '.$salt, file_get_contents($this->laravel->environmentFilePath()) )); } /** * Generate a random salt for the application. * * @return string */ protected function generateRandomSalt() { return bin2hex(random_bytes(16)); } }