Ejemplo n.º 1
0
 /**
  * Generate a secure key for use in cryptographic methods, optionally setting it in `app/config/config.php`.
  *
  * eg: `gen aes set`
  * eg: `gen sha 32 set-lead`
  * eg: `gen sha 32 set-tail`
  *
  * @param array $args The arguements.
  */
 public function gen($args)
 {
     if ($args[0] == 'aes') {
         $r = \Disco\manage\Manager::genAES256Key();
         if (isset($args[1]) && $args[1] == 'set') {
             \Disco\manage\Manager::setAES256Key($r);
             echo '`AES_KEY256` now set to : ' . $r . PHP_EOL;
         } else {
             echo $r . PHP_EOL;
         }
         //el
     } else {
         if ($args[0] == 'sha') {
             if (empty($args[1])) {
                 echo 'You must specify a length for the SHA512 salt' . PHP_EOL;
                 exit;
             }
             //if
             $s = \Disco\manage\Manager::genSalt($args[1]);
             if (!empty($args[2]) && $args[2] == 'set') {
                 \Disco\manage\Manager::setSalt($s);
                 echo '`SHA512_SALT` now set to : ' . $s . PHP_EOL;
             } else {
                 echo $s . PHP_EOL;
             }
             //el
         } else {
             echo 'You must specify what to gen, either `aes` or `sha`' . PHP_EOL;
         }
     }
     //el
 }