/** * benchValidate * * @since 3.0.0 * * @param array $parameterArray * * @ParamProviders({"providerHash"}) */ public function benchValidate($parameterArray = []) { /* setup */ $hash = new Hash($this->_config); $hash->init($parameterArray[0]); /* bench */ $hash->validate($parameterArray[0], function_exists('password_verify') ? $parameterArray[1][0][1] : $parameterArray[1][1]); }
/** * validate the captcha * * @since 2.2.0 * * @param string $task plain task * @param string $hash hashed solution * * @return integer */ public function validate($task = null, $hash = null) { $output = ValidatorInterface::FAILED; $captchaHash = new Hash(Config::getInstance()); /* validate captcha */ if ($task && $captchaHash->validate($task, $hash)) { $output = ValidatorInterface::PASSED; } return $output; }
/** * validate the password * * @since 2.6.0 * * @param string $password plain password * @param string $hash hashed password * * @return integer */ public function validate($password = null, $hash = null) { $output = ValidatorInterface::FAILED; $passwordHash = new Hash(Config::getInstance()); /* validate password */ if ($password && $passwordHash->validate($password, $hash)) { $output = ValidatorInterface::PASSED; } return $output; }
/** * testValidate * * @since 2.6.0 * * @param string $raw * @param array $hashArray * * @dataProvider providerHash */ public function testValidate($raw = null, $hashArray = array()) { /* setup */ $hash = new Hash($this->_config); $hash->init($raw); /* actual */ $actual = $hash->validate($raw, function_exists('password_verify') ? $hashArray[0][1] : $hashArray[1]); /* compare */ $this->assertTrue($actual); }