/** * {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 ::generateSha256 * @covers ::generateSha2 * @dataProvider providerTestGenerateSha2 */ public function testGenerateSha256($password, $rounds) { $hash = $this->hash->generateSha256($password); $this->assertTrue(password_verify(md5($password), $hash)); }