コード例 #1
0
ファイル: REST.php プロジェクト: nextglory/CacoCloud
 /**
  * DELETE /password/:key/:id
  *
  * @param string $key
  * @param int $id
  */
 public function delete($key, $id)
 {
     $container = new Container();
     if ($container->read($id) && $this->crypto->decrypt($container->getContainer(), $key) !== false) {
         $this->app->render($container->delete() ? 200 : 500, ['response' => $id]);
     } else {
         $this->app->render(404);
     }
 }
コード例 #2
0
ファイル: AccountMcrypt.php プロジェクト: nextglory/CacoCloud
 /**
  * Edit the mail account specified by its id and matches the given key.
  *
  * @param string $key
  * @param int $id
  * @param Account $account
  * @return bool
  */
 public function edit($key, $id, Account $account)
 {
     if (!$this->one($key, $id)) {
         return false;
     }
     $mailAccount = new MailAccount();
     $mailAccount->read($id);
     $mailAccount->setContainer($this->crypto->encrypt(serialize($account), $key));
     return $mailAccount->save();
 }
コード例 #3
0
 /**
  * Runs the cli
  *
  * @return int
  */
 public function run()
 {
     $countChanged = 0;
     $from = $this->getArg('f', 'from', null, true);
     $to = $this->getArg('t', 'to', null, true);
     $cipher = $this->getArg('c', 'cipher', $this->crypto->getCipher());
     $this->crypto->setCipher($cipher);
     $this->printLine("Using the cipher: {$cipher}");
     $this->printLine("Changing the key {$from} to {$to}");
     $container = new Container();
     $containerList = $container->readList();
     foreach ($containerList as $container) {
         /** @var Container $container */
         $data = $this->crypto->decrypt($container->getContainer(), $from);
         if ($data === false) {
             continue;
         }
         $container->setContainer($this->crypto->encrypt($data, $to));
         $container->save();
         $container->clear();
         $countChanged++;
     }
     $this->printLine("Changed {$countChanged} passwords");
 }