Example #1
0
 /**
  * {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);
 }
Example #2
0
 /**
  * @covers ::generateSha512
  * @covers ::generateSha2
  * @dataProvider providerTestGenerateSha2
  */
 public function testGenerateSha512($password, $rounds)
 {
     $hash = $this->hash->generateSha512($password);
     $this->assertTrue(password_verify(md5($password), $hash));
 }