/** * {inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $hash = new Hash(); $password = $input->getArgument('password'); $type = $input->getOption('type') ? $input->getOption('type') : 'bcrypt'; switch ($type) { case 'sha256': $out = $hash->generateSha256($password); break; case 'sha512': $out = $hash->generateSha512($password); break; case 'bcrypt': $out = $hash->generateBcrypt($password); break; default: throw new \RuntimeException("Invalid hash type specified"); } $output->writeln($out); }
/** * @covers ::generateBcrypt * @dataProvider providerTestGenerateBcrypt */ public function testGenerateBcrypt($password, $cost) { $hash = $this->hash->generateBcrypt($password, $cost); $this->assertTrue(password_verify(md5($password), $hash)); }