Skip to content

Instantly share code, notes, and snippets.

@chronon
Created January 24, 2013 19:09
Show Gist options
  • Save chronon/4626569 to your computer and use it in GitHub Desktop.
Save chronon/4626569 to your computer and use it in GitHub Desktop.
A CakePHP 2.x console command that prints random Security.salt and Security.cipherSeed.
<?php
/* SecurityGenShell - prints randmom Security.salt and Security.cipherSeed for
* Config/core.php
*
* See lib/Cake/Console/Command/Task/ProjectTask.php securitySalt() and
* securityCipherSeed().
*
* Installation: put this file, named `SecurityGenShell.php`, in `APP/Console/Command`.
* Usage: run `Console/cake security_gen` - copy and pasted the values to
* APP/Config/core.php.
*/
App::uses('Security', 'Utility');
class SecurityGenShell extends AppShell {
public function main() {
$this->stdout->styles('red', array('text' => 'red'));
$securitySalt = Security::generateAuthKey();
$this->out('Security.salt: <red>' . $securitySalt . '</red>');
$securityCipherSeed = substr(bin2hex(Security::generateAuthKey()), 0, 30);
$this->out('Security.cipherSeed: <red>' . $securityCipherSeed . '</red>');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment