/** * 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"); }