Skip to content

Commit

Permalink
Use Security::randomBytes(64) for the newKey
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Nov 13, 2016
1 parent e5005a3 commit 615ae01
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Console/Installer.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace App\Console;

use Cake\Utility\Security;
use Composer\Script\Event;
use Exception;

Expand Down Expand Up @@ -174,17 +175,19 @@ public static function setSecuritySalt($dir, $io)
$config = $dir . '/config/app.php';
$content = file_get_contents($config);

$newKey = hash('sha256', $dir . php_uname() . microtime(true));
$newKey = hash('sha256', Security::randomBytes(64));
$content = str_replace('__SALT__', $newKey, $content, $count);

if ($count == 0) {
$io->write('No Security.salt placeholder to replace.');

return;
}

$result = file_put_contents($config, $content);
if ($result) {
$io->write('Updated Security.salt value in config/app.php');

return;
}
$io->write('Unable to update Security.salt value.');
Expand Down

0 comments on commit 615ae01

Please sign in to comment.